JSON formatter
DevNo. 38 / 84
Format, minify and validate JSON in your browser, with a line and column for every error and an optional sort that puts keys back in order.
JSON has no comments and no trailing commas. JavaScript has a lot to answer for.
work surface
Math, not advice — results are indicative.Read the disclaimer.
most-used utilities
Read an API response
Paste a response body and see its shape indented and countable instead of one long line.
Find the missing comma
The caret points at the exact character, so the fix takes seconds instead of a coffee.
Diff two configs
Sort the keys in both files and the real changes stop hiding among reordered lines.
pro tips
Trailing commas and comments are JavaScript habits, not JSON. The parser will find them for you, usually within a second and with a caret.
Sort keys before comparing two config files. Identical data in a different order looks like a rewrite, and reviewers deserve better.
Minify a payload before stuffing it into an environment variable. Newlines are usually the thing that breaks the shell, not the JSON itself.
what it does
Paste JSON and pick a mode: pretty prints it with a two-space indent, minify squeezes out every space it can, and validate comes back with a report instead of a wall of text. Everything happens as you type, in the browser, with no upload and no waiting for a server to have an opinion.
The error report is the useful part. When a brace is missing or a comma wandered off, you get the line, the column, the character position and a small excerpt with a caret under the suspect. No more scrolling through four hundred lines looking for the one quote mark that went on holiday.
A typical API response with 40 lines and a two-space indent runs about 1,150 characters; minified it lands near 720. The stats line does that arithmetic for you, which is handy when a payload has to fit inside a header, an environment variable or someone's patience.
Formatting never changes the values, only the whitespace. Sorting keys does change the order, which is the point: two files with the same data in the same order produce a readable diff. Two caveats worth knowing — JSON numbers beyond 15 digits and duplicate keys are already settled by the parser before this tool sees them.
quick answers
Why won't my JSON parse?
Comments, trailing commas, single quotes and unquoted keys are all valid JavaScript and all invalid JSON. The error line points at the first one it meets, with a caret under the offending character.
Does formatting change my data?
No. Indentation and line breaks are cosmetic. The sort option reorders object keys but keeps every value, and arrays keep their order either way.
Is my JSON sent anywhere?
No. Parsing runs on your machine with the browser's own JSON engine. Nothing is uploaded, logged or remembered after you close the tab.