JSON Formatter
Paste minified or messy JSON and get a clean, indented version you can read, copy or download. If the text is not valid JSON, the tool points to the exact line and column and explains the likely cause, such as a trailing comma or single quotes. Number digits and string escapes are kept exactly as you wrote them.
Format and Beautify Your JSON
Where the error is
Formatted JSON
Warnings
About this JSON
How to Use the JSON Formatter
- Paste your JSON into the box (a small example is already there).
- Pick 2 spaces, 4 spaces or a tab for indentation, and tick Sort object keys if you want alphabetical order.
- Press Format. Read the result, then use Copy or Download.
- If something is wrong, the message shows the line and column, and the offending character is selected in your input.
About This Tool
Developers reading API responses, testers comparing payloads, analysts cleaning exported data and anyone who needs a config file to be readable.
Input: JSON · Output: Formatted JSON (.json).
Features and Limitations
Features
- Errors with line, column, a short excerpt and a plain-English hint (trailing comma, single quotes, unquoted keys, comments, missing commas).
- Large numbers are never rounded: the tool re-indents the text instead of re-serialising it, and warns when a number exceeds what JavaScript can store exactly.
- Optional recursive key sorting, 2/4-space or tab indentation.
- Handles files of several megabytes in your browser without uploading them.
Limitations
- Only strict JSON is accepted. JSON5, JSONC, comments, trailing commas and single quotes are reported as errors, not silently fixed.
- Sorting keys changes the order of properties, which is harmless for most programs but visible in diffs.
- Duplicate keys are kept as written (use the JSON Validator to list them).
- Very large inputs (tens of megabytes) may be slow or run out of browser memory.
- Results are computed in your browser; nothing you enter is sent to a server.
Example
The input {"b":1,"a":[1,2]} with 2 spaces and key sorting becomes four lines per property: "a" first, then "b". The input {"a":1,} fails with “Trailing comma before }” at line 1, column 7.
Frequently Asked Questions
Is my JSON uploaded anywhere?
No. The text is parsed by JavaScript in your browser and never leaves your device.
Why does it say my JSON is invalid when it works in my code?
The tool follows the JSON standard strictly. Many programs accept extras such as comments, single quotes, trailing commas or unquoted keys, but those are not valid JSON and other parsers will reject them. The message tells you which one it found.
Does formatting change my data?
No values are changed. Whitespace is rewritten; numbers such as 1.0, 1E3 or 12345678901234567890 and escapes such as \u00e9 are kept exactly as typed. Only the optional key sorting reorders properties.
What do the line and column mean?
Line and column are counted from 1 in your input. The column counts characters from the start of the line, and a tab counts as one character.
Can it format JSON Lines (NDJSON)?
Not as one document, because a file with several top-level values is not valid JSON. Format one line at a time, or wrap the lines in an array first.
Related Tools
More like this: all Format & Validate tools, all Developer & Web tools or the TinySandy home page.