How to format JSON
- Paste your JSON into the box, such as an API response or a config file.
- Choose 2 spaces or 4 spaces next to Indent.
- Select Format JSON.
- Select Copy result to copy the formatted JSON, or Clear to start over.
For example, this one-line input: {"name":"Ada","active":true,"tags":["admin","dev"]} comes out with one key per line, each nested level pushed in by 2 spaces, and each array item on its own line. The data is the same. Only the layout changes.
Valid JSON rules, with examples
Most "invalid JSON" errors come from writing JavaScript-style objects. JSON is stricter. This table shows the usual problems and the fix.
| Invalid | Valid | Rule |
|---|---|---|
| {'name': 'Ada'} | {"name": "Ada"} | Strings and keys need double quotes |
| {name: "Ada"} | {"name": "Ada"} | Every key must be quoted |
| {"a": 1, "b": 2,} | {"a": 1, "b": 2} | No comma after the last item |
| [1, 2, 3,] | [1, 2, 3] | No trailing comma in arrays either |
| {"a": 1 // note} | {"a": 1} | Comments are not allowed |
| {"a": NaN} | {"a": null} | NaN, Infinity and undefined are not JSON values |
How to fix invalid JSON
When parsing fails, the result box shows Invalid JSON followed by your browser's own error message. In Chrome and Edge it often names the spot. For {"name": "Ada", "age": 36,} the message ends with (line 1 column 27), which points at the closing brace right after the stray comma. Remove that comma and format again.
The wording differs between browsers, and some messages give no position. For a line and column, paste the same text into the JSON Validator.
Things the formatter changes without asking
The tool reads your JSON with JSON.parse and writes it back out with JSON.stringify. That is standard and safe for most data, but a few values come out different from what you pasted.
- Whole numbers larger than 9,007,199,254,740,991 lose precision.
9007199254740993becomes9007199254740992. Store big IDs as strings if exact digits matter. - Numbers are rewritten in a shorter form:
1.0becomes1and1e2becomes100. - If a key appears twice in one object, only the last value is kept.
- Keys that look like whole numbers move to the front in number order.
{"b":1,"10":2,"2":3}comes out as 2, 10, then b. Other keys keep their order. - Escapes such as
\u00e9are turned into the real character, in this case é.
What this tool does not do
This page only pretty-prints. There is no tab indent option, no key sorting and no tree view. To go the other way and strip all spaces and line breaks, use the JSON Minifier, which also tells you how many characters it removed.
Common Mistakes to Avoid
Pasting a JavaScript object instead of JSON
Solution:
Formatting JSON that contains very large ID numbers
Solution:
Pasting only part of a response
Solution:
Expecting the formatter to repair broken JSON
Solution:

