Guides

How to format, validate and fix JSON

By PulseTech Editorial · Published 16 November 2026

JSON is the format most web APIs and many configuration files use. It is simple, but unforgiving: a single missing quote stops a whole file from loading. This guide covers reading JSON comfortably, finding errors quickly, and the mistakes behind most of them.

Make it readable

APIs usually send JSON on one long line to save space. That is fine for computers and hard for people. Paste it into JSON Formatter and it is shown with each key on its own line and nested objects indented.

  • 2 spaces is the most common style in JavaScript projects.
  • 4 spaces is common in Python and Java projects.
  • Tabs suit teams whose editors are set up for them.

Ticking Sort keys orders every object's keys alphabetically. That helps when you compare two versions of the same data, for example with Text Compare: differences in values stand out instead of hiding behind keys that merely moved.

Find the error

When JSON is invalid, the formatter tells you the line and column where reading stopped. The real mistake is usually at that point or just before it. If you only need a yes or no, JSON Validator checks validity without reformatting.

The five mistakes behind most JSON errors

  1. Trailing commas. {"a": 1, "b": 2,} is allowed in JavaScript but not in JSON. Remove the last comma.
  2. Single quotes. JSON needs double quotes around keys and text: {"name": "Sam"}, never {'name': 'Sam'}.
  3. Unquoted keys. {name: "Sam"} is a JavaScript object, not JSON. Every key needs quotes.
  4. Comments. JSON has no comments. Remove // ... and /* ... */, or use a format such as JSONC if your tool supports it.
  5. Unescaped characters in text. A line break or a double quote inside a string must be written as \n or \".

A sixth, less common one: values like NaN, Infinity or undefined are not valid JSON. Use null or a number.

Make it compact again

Before sending JSON in a request or storing it, you can remove the spaces again with JSON Minifier. The data is identical; only the whitespace goes.

Related jobs

  • Data inside JSON is sometimes Base64-encoded. Base64 Decoder turns it back into text.
  • Values that go into a URL must be percent-encoded; use URL Encoder.
  • Sign-in tokens (JWTs) carry JSON inside them. JWT Decoder shows their contents and expiry, without verifying the signature.

A note on privacy

API responses often contain customer data or keys. These tools run in your browser, so what you paste is processed on your own device and is not sent to our server. Even so, remove secrets before sharing formatted JSON with anyone else.

jsondeveloper toolsapi

Keep reading