How to format and validate JSON online
- Paste your JSON into the left Input box, or click Sample to drop in an example you can experiment with.
- Choose your indentation from the Indent menu,
2 spaces(the default most linters andpackage.jsonfiles use),4 spaces, orTabs, then click Format to pretty-print it. - Need the opposite? Click Minify to strip every space and newline and collapse the whole document onto a single line.
- Take the result with Copy output, or save it with Download .json. If the input is broken, the status line names the error and points at the exact spot instead.
Why pretty-print or minify JSON?
Real-world JSON almost never arrives readable. A response from curl, a webhook payload, or a value copied out of a log is usually one dense line with no line breaks, impossible to scan for the one field you care about. Pretty-printing re-indents it into a tree you can actually read, so a nested user.address.city becomes obvious at a glance and you can count brackets by eye. It also makes diffs sane: two formatted files show a one-line change where two minified blobs show the entire line as changed.
Minifying goes the other way and matters when bytes cost money or milliseconds. Stripping whitespace from a 40 KB config can shave several kilobytes before gzip, which is worth it for an API response sent thousands of times a second or a JSON blob embedded in an HTML data attribute. A common workflow is to format while you are editing and debugging, then minify the final version right before you paste it into code or ship it. Both operations are lossless, the data is byte-for-byte identical, only the spacing between tokens changes.
Common JSON errors and how to spot them
JSON looks like JavaScript but the rules are stricter, and that gap causes most parse failures. The validator runs the same parser your code does, so if it complains here, your app will too, and the line and column it reports usually sit right after the real mistake. The usual suspects:
- Trailing comma,
{"a": 1,}or a comma after the last array item is legal in JavaScript but forbidden in JSON. The error points at the closing brace or bracket that followed it. - Single quotes,
{'name': 'Ada'}fails; JSON only allows double quotes around both keys and string values. - Unquoted keys,
{name: "Ada"}is a JavaScript object literal, not JSON. Every key must be a quoted string. - Stray or missing commas, two values with no comma between them, or an extra comma, both stop the parser at the next token.
- Smart quotes and hidden characters, text pasted from a word processor can carry curly “quotes” or a non-breaking space that look right but aren't valid ASCII quotes.
Frequently asked questions
How do I format messy JSON?
Paste it into the Input box and click Format. The tool re-indents the whole document with your chosen indentation, 2 spaces, 4 spaces or tabs, and validates it in the same pass, so a valid result also confirms the JSON parses.
What does the validator tell me when the JSON is invalid?
You get the exact parser error along with the line and column of the problem. Because the parser stops at the first thing it can't accept, the real mistake is usually just before the reported position, most often a trailing comma, a missing comma, unquoted keys or single quotes.
What is the difference between Format and Minify?
Format (beautify) adds indentation and line breaks so a human can read the structure. Minify removes every space and newline to make the payload as small as possible for transport or storage. Both are lossless, the underlying data is identical, only the whitespace differs.
Why does my JSON fail on a trailing comma when my editor accepts it?
Your editor is probably parsing it as JavaScript or JSON5, which permit trailing commas. Strict JSON, what APIs, JSON.parse() and most parsers use, does not. Delete the comma after the last item in the object or array and it will validate.
Is there a size limit, and can I format large API responses?
There is no hard size limit. Everything runs in your browser using the native JSON engine, so a few megabytes format almost instantly; only extremely large files are bounded by your device's memory rather than any server.
Is it safe to paste production data here?
Yes. The formatter runs entirely on your device, nothing you paste is uploaded, logged or stored. Once you have clean JSON you can convert it with JSON to CSV for a spreadsheet, or go the other way with CSV to JSON.