JSON Formatter

Paste JSON to pretty-print it, minify it, or find out exactly where it breaks — with the line, the column and a plain-English explanation.

Runs entirely in your browser — nothing is uploaded

Output style

What this does

Paste JSON in the left box and the formatted version appears on the right as you type. Switch between pretty-printed and minified, choose your indent, and optionally sort every object's keys. If the JSON is broken, you get the line, the column, the offending text with a caret under it, and a sentence explaining what went wrong.

Error messages that say something

Most validators pass along whatever the browser said, which is usually"Unexpected token } in JSON at position 42" — and worded differently in every browser. That tells you where to look but not what you did. This one reads the JSON itself, so it can name the mistake:

  • Trailing commas — the single most common cause, and legal in JavaScript, which is why it catches people out.
  • Single quotes — valid JavaScript, invalid JSON.
  • Curly quotes — “ ” instead of " ", which is what you get pasting out of a document or a chat app.
  • Unquoted property names — again fine in JavaScript, not in JSON.
  • Python valuesTrue, False and None instead of true, false and null.
  • Comments, which JSON has never allowed.
  • Unclosed brackets and strings, pointing at the bracket that was never closed rather than the end of the file.

Your numbers survive

Most formatters parse your JSON into memory and print it back out. That quietly damages a few things, and the damage is easy to miss. JavaScript numbers lose precision above about 9 quadrillion, so a 64-bit database id like 9007199254740993 comes back as...992 — off by one, silently, in a value you were probably using to identify a record. Keys that look like integers get hoisted to the front of the object, and duplicate keys are thrown away without a word.

This formatter reworks the text rather than the parsed values, so every number is reproduced exactly as you wrote it, keys stay in their original order unless you ask for sorting, and if the same key appears twice in one object you get told about it rather than losing one.

Pretty or minified?

Pretty-print while you're reading, debugging or committing a config file to a repository — indentation is what makes a diff readable. Minify for anything travelling over a network, where the whitespace is pure overhead. Minifying typically strips 15–30% of a formatted file, though if your server compresses responses with gzip or brotli the real-world saving is much smaller, because compression handles repeated indentation very well.

Sorting keys

JSON objects have no defined order, so two files can hold identical data and still show up as completely different in a diff. Sorting both puts the keys in the same sequence and reduces the difference to the parts that actually changed. It's the quickest way to compare two API responses or two versions of a config file.

Is it private?

Yes, and it's worth being specific because JSON often carries API keys, tokens and customer records. The parsing and formatting happen in JavaScript inside this page. Nothing you paste is transmitted, logged or stored — there is no server on the other end to receive it. Load the page, disconnect from the internet, and it carries on working.

Frequently asked questions

How large a file can it handle?

Comfortably into the megabytes. It all runs in your browser tab, so the ceiling is your device's memory rather than an upload limit, and there's no queue.

Can it handle JSON Lines or NDJSON?

Not as a single document — those formats put one JSON value per line, and a JSON document holds exactly one value. You'll get a "more content after the JSON value ends" error. Wrap the lines in [ ] with commas between them and it will format the lot.

Why is my trailing comma an error?

Because JSON's specification doesn't allow one, even though JavaScript, Python and most compilers do. It's the most-reported error here by a wide margin. JSON5 and JSONC permit trailing commas and comments, but they're different formats — most parsers expecting JSON will reject them.

Does formatting change my data?

No. Whitespace between tokens carries no meaning in JSON, so pretty-printing and minifying produce a file that parses to exactly the same value. The only options that change anything are sorting keys, which reorders them, and even that leaves the data identical.

← Browse all Gwibbo tools