Developer Tools
JSON Formatter
Format, validate, and minify JSON with line and character counts.
Valid JSON
About the JSON formatter
Paste JSON and pick an action. Format prints it with 2 spaces, 4 spaces or tabs of indentation, Minify removes every space and line break outside strings, and Validate only checks it. The output gets syntax highlighting and a copy button, and above it you can see how many lines and characters your input has. Parsing uses the browser's own JSON.parse, which follows the JSON standard to the letter: keys and strings need double quotes, and comments, trailing commas and single quotes are errors. When something is wrong you see what the parser expected and where. In Chrome and Edge the tool turns that position into a line number, which saves counting characters in a long file. Because the JSON becomes a JavaScript value and back again, three things can change. Whole numbers above 9,007,199,254,740,991 lose precision, so an ID like 12345678901234567890 comes out as 12345678901234567000. When a key appears twice, only the last value survives. And keys that look like whole numbers move to the front in ascending order. Everything else keeps its order, and the JSON never leaves your browser.
Frequently asked questions
Can it format JSON with comments?
No. Comments aren't part of the JSON standard (RFC 8259), so the parser stops at the first // or /* and reports an error. Strip the comments first. If you need them, a format that allows comments, such as JSONC or YAML, is the better fit.
Will it sort my keys alphabetically?
No, keys keep the order they have in your input. The one exception is keys made only of digits, such as "1" or "42", which JavaScript always lists first in ascending order. For sorted keys, run the file through jq -S or sort them in your editor.
What does Validate do that Format doesn't?
Nothing extra. Both run the same parser and show the same error message; Validate just leaves the output area alone. The label under the buttons reads Valid JSON whenever there is no error to report.
Is it safe to paste API responses with tokens in them?
The JSON is parsed and formatted in your browser and isn't sent to a server. Still treat tokens and keys as secrets: close the tab when you're done, and rotate any key that has ended up somewhere you don't control.