How to use the JSON formatter
Paste your JSON into the JSON formatter’s input box, whether it came from an API response, a log file or a config you are editing. Then choose an action. Format re-indents the data with either 2 or 4 spaces per level, putting each key on its own line so the structure is easy to follow. Minify does the opposite and strips all optional whitespace, which is handy before you embed JSON in a URL, an environment variable or a request body.
When the result looks right, press the copy button to put it on your clipboard. Everything runs locally in the browser tab, so the JSON formatter is safe to use with access tokens, internal endpoints or personal data that should never be uploaded to a third-party service.
How it works
The tool first parses your text with the browser’s built-in JSON parser, the same strict one that JSON.parse uses in JavaScript. If parsing succeeds, the data is printed back out with the indentation you picked, or with none at all for minify. Because the output is generated from the parsed data rather than by shuffling characters around, the result is always valid JSON.
If parsing fails, you get the line and column where the parser gave up. That position usually points to the character right after the real mistake, so look at the end of the previous line as well.
A small before-and-after example with 2-space indentation:
{"order":1042,"items":[{"sku":"MUG-01","qty":2}],"paid":true}
{
"order": 1042,
"items": [
{
"sku": "MUG-01",
"qty": 2
}
],
"paid": true
}
Fixing common JSON errors
- Trailing commas.
[1, 2, 3,]is fine in modern JavaScript but invalid in JSON. Remove the comma after the last item in every array and object. - Single quotes. Strings and keys must use double quotes:
"name", not'name'. - Unquoted keys.
{id: 7}must become{"id": 7}. - Comments. Neither
//nor/* */is allowed. If you need notes in a config file, consider a format such as JSONC or YAML, or store the note as a regular string field. - Special values.
undefined,NaNandInfinitydo not exist in JSON; usenullor a number instead.
One more thing worth knowing: the formatter validates your JSON with the browser’s parser but reprints it from the original text tokens rather than re-serializing parsed JavaScript numbers. That means a very large integer, a trailing zero like 1.10, or a -0 keeps its exact original digits instead of being rounded or rewritten the way JSON.stringify(JSON.parse(x)) would do it.