JSON Formatter
Format, validate and inspect JSON data.
About JSON Formatter
API responses, log lines and config exports often arrive as one long line of JSON. That is hard to read during debugging or code review. Developers, QA testers and support staff paste that blob here to see the nesting, spot a missing field, or copy a readable version into a ticket or a pull request comment.
How it works
The tool runs two built-in browser functions: JSON.parse reads your text, and JSON.stringify writes it back out with a two-space indent. Nothing is sent to a server. Because the input is fully parsed first, any syntax error stops the run and shows the parser's error message instead of a result. Key order is kept as written. Duplicate keys collapse to the last value, and integers larger than 9007199254740991 can lose precision. The result can be saved as formatted.json.
How to use JSON Formatter
- Enter the text or data in the format shown in the text box above (Paste JSON).
- Select “Run tool” and check the result before copying or downloading it.
Worked example
Input: {"name":"Ana","tags":["a","b"],"age":30}. Output, with two-space indentation: an opening brace, then "name": "Ana", then "tags": [ with "a" and "b" each on their own line indented four spaces, then the closing bracket, then "age": 30, and a closing brace. Each array item gets its own line, and every key keeps its original position.
Tips for a better result
- If you copied JSON from a JavaScript file, convert single quotes to double quotes and remove trailing commas first, because strict JSON parsing rejects both.
- Very large IDs, such as 64-bit database keys, can be rounded during parsing. Ask the API to send them as strings if exact digits matter.
- Comments like // note are not valid JSON. Delete them before formatting, or the parser reports an unexpected token.
Frequently asked questions
Why does it say Unexpected token instead of formatting?
The text is not strict JSON. Common causes are single quotes, trailing commas, comments, unquoted keys, or a value like undefined. The message usually includes a position, so check the characters near that point.
Will it reorder or sort my keys?
No. Keys come out in the order they were parsed. The one exception is a key that appears twice in the same object. Only the last occurrence survives, in the position where the key first appeared.
Can I choose tabs or four-space indentation?
No. The indent is fixed at two spaces. If your project uses a different style, run the output through your editor's formatter or a linter with your own settings.
What to check
A formatted or parsed result is not proof that code is secure, correct or production-ready. Never paste production secrets.
Read the Privacy Policy for information about local processing, connected services and advertising.