JSON formatter — validate, fix and beautify JSON
A JSON formatter pretty-prints a messy or one-line JSON string into clean, indented, readable text — and flags exactly where it breaks. Carbide's JSON formatter does both: paste a payload, get beautified JSON with sorted keys, or a precise line-and-column error if it is invalid. It runs entirely in your browser, so the data you paste is never uploaded.
Below is how to format and validate JSON, why the common errors happen, how to read the error message to fix a payload fast, and how to minify it again for production.
Format and pretty-print JSON with sorted keys
Formatting is the everyday job: an API returns one long line, a log dumps a compact object, and you need to actually read it. Paste it into the JSON formatter and it re-indents the structure with consistent spacing, one property per line, so the shape is obvious at a glance. Sorting keys alphabetically makes it easier to scan large objects and to compare two versions of the same payload later.
The result is valid, standards-compliant JSON — the tool never changes your values, only the whitespace and key order. Copy it back into your editor, save it to a file, or hand it to a teammate who has to make sense of the same response.
Why is my JSON invalid? The common errors
Most invalid JSON fails for a handful of predictable reasons, and the JSON formatter points at the exact character that broke the parse. Once you know the usual suspects, fixing a payload takes seconds rather than minutes of squinting.
- Trailing comma after the last item in an object or array — JSON forbids it, even though JavaScript allows it.
- Single quotes instead of double quotes — JSON strings and keys must use double quotes.
- Unquoted keys — every property name needs quotes ({ name: 1 } is invalid, { "name": 1 } is valid).
- Comments — plain JSON has no // or /* */; strip them before parsing.
- A stray value like undefined, NaN or a leading zero, which are not part of the JSON spec.
Read the error message to fix payloads fast
When JSON is invalid, the message that matters is the location. The JSON formatter reports the line and column where parsing stopped, so instead of hunting through a 2,000-character blob you jump straight to the problem. A message like "Unexpected token } at line 14, column 3" almost always means a missing comma on the line above or an extra one on that line.
The workflow is simple: paste, read the line and column, jump there, fix the one character, and re-run. Because the tool re-validates on every paste, you get instant confirmation the moment the JSON is clean — no submit button, no round-trip to a server.
Minify JSON for production
Pretty JSON is for humans; production wants it small. The same JSON formatter minifies in one click — it strips every space, tab and newline and returns the tightest valid representation of the exact same data. For a config file, an API response cache or a payload you are embedding in a URL, that can cut the size noticeably with zero loss of information.
Minifying and beautifying are reversible: minify to ship, then paste the compact string back and beautify whenever you need to read or debug it again. Nothing about the data changes between the two forms — only the whitespace.
Paste API payloads safely — your data never leaves the browser
This matters more with JSON than with almost any other format, because the JSON you paste is often real: a customer record, an auth token, an order object, an internal API response. Pasting that into a random ad-heavy formatter means handing your data to a server you do not control. The JSON formatter parses, formats, validates and minifies entirely on your device — nothing is uploaded, logged or retained.
That is a genuine differentiator, not a slogan: because there is no server doing the work, there is nothing to leak. You can format a production payload, a webhook body or a secrets-laden config with the same confidence you would have in your own editor.
JSON vs JSONC and JSON5, and comparing two payloads
Strict JSON has no comments, no trailing commas and no unquoted keys — that is the format the JSON formatter validates against. JSONC (JSON with comments) and JSON5 are relaxed supersets used in config files like tsconfig.json; they add comments and looser syntax, but a JSON parser will reject them, so strip the extras before validating strict JSON.
When you need to see what changed between two versions of a payload — a before-and-after from an API, or two config files that should match — format both first so their key order and indentation line up, then drop them into the diff checker to highlight every added, removed and changed line. For beautifying JavaScript, CSS and XML alongside JSON, the code formatter and minifier guide covers the rest of the family.
Frequently asked questions
How do I validate JSON online?
Paste your JSON into the JSON formatter — it validates instantly and either beautifies the data or shows the exact line and column where the syntax breaks. There is no submit button; validation runs the moment you paste.
Is my JSON uploaded to a server?
No. The JSON formatter parses, formats and validates entirely in your browser — your data never leaves your device. That makes it safe for real API payloads, tokens and customer records.
Why does my JSON say invalid when it looks fine?
The usual causes are a trailing comma after the last item, single quotes instead of double quotes, or unquoted keys — all valid in JavaScript but not in JSON. The error message points at the line and column so you can fix the one character quickly.
Is the JSON formatter free, and is there a size limit?
Yes, it is completely free with no sign-up and no pro upsell. Because processing happens on your device, the practical limit is your browser's memory rather than an artificial cap — everyday payloads, even large ones, format comfortably.
How do I compare two JSON payloads?
Format both payloads first so their key order and indentation match, then paste them into the diff checker to see every added, removed and changed line highlighted side by side.
A good JSON formatter reads your data, tells you precisely what is wrong, and never sends it anywhere. Use the JSON formatter to beautify and validate a payload, minify it for production, and reach for the diff checker when you need to compare two versions — all free, all in your browser.