JSON formatter
input.json
Paste your JSON here
or drop a .json file anywhere here
Formatted output appears here.
What formatting actually does
Formatting JSON is a parse followed by a re-serialise. The document is read into a value, then written back out with newlines after every comma and a fixed indent per nesting level. Nothing about the data model changes — only the bytes between the tokens.
That distinction matters because two things are normalised on the round trip, and it is worth knowing which:
- Numbers are re-printed in their shortest form.
1.50becomes1.5,1e3becomes1000, and-0becomes0. The value is identical; the spelling is canonical. - Unnecessary string escapes are dropped.
"A"becomes"A". Escapes that JSON requires — quotes, backslashes, and control characters — are kept. - Integers above 253−1 lose precision. This is a property of the JavaScript number type, not of this tool. Carry large IDs as strings.
Choosing an indent width
The indent selector applies immediately and is remembered for your next visit. As a rule of thumb:
- 2 spaces — API responses, anything you will paste into a code review, and anything that has to match
JSON.stringify(v, null, 2)output. - 4 spaces — hand-edited configuration files where nesting is shallow but lines are long.
- Tab — files committed to a repository where contributors disagree about width, or when byte count matters slightly.
The same job on the command line
jq . input.json formats with a 2-space indent, which is the same output this page produces at its default setting — theJSON pretty print page lists the equivalent one-liner for Python, Node, Go, Ruby, and PowerShell, along with the flags each of them gets wrong by default. The browser version wins when the JSON is in your clipboard rather than a file, when you want to click through a tree instead of reading 4,000 lines, or when the payload is something you would rather not pipe through a tool you have not audited.
Formatting a document that will not parse
A formatter cannot indent what it cannot read, so an invalid document gives you an error instead of output. The error panel shows the line, the column, the offending source line with a caret beneath the exact character, and what the parser expected there. Jump to errorputs your cursor on that character. If the problem is one of the common near-JSON mistakes,Repair fixes it and formats in one step — see thevalidator for the full catalogue of causes.
Common questions
Does formatting change my data?
Only whitespace, unless you also press Sort keys. Property order, array order, and every value are preserved exactly as the parser read them. See the note on number and string normalisation above for the two edge cases.
Should I indent with 2 spaces, 4 spaces, or tabs?
Two spaces is the de-facto default for JSON — it is what JSON.stringify(value, null, 2), jq, and Prettier all emit. Four spaces suits deeply nested config a human edits by hand. Tabs let each reader pick their own width and are marginally smaller on disk.
Can I format JSON that is not valid yet?
Not directly — formatting requires a parse. Press Repair first: it fixes trailing commas, single quotes, unquoted keys, and comments, then formats the result.
Why did my large number change?
JavaScript numbers are IEEE 754 doubles, so integers beyond 2^53−1 lose precision on parse. If your payload carries 64-bit IDs or high-precision decimals, keep them as strings in the JSON. This affects every JSON tool built on a JavaScript engine, including Node.
The rest of the toolkit
Same engine, same privacy — every page runs entirely in your browser.
JSON viewer
Expand, collapse, and search a JSON tree; copy any value or its path.
JSON validator
Find syntax errors with exact line, column, and a suggested fix.
JSON minifier
Strip whitespace and see the byte savings before and after.
JSON beautifier
Turn minified or broken JSON into clean, highlighted output.
JSON pretty print
Readable indentation with optional deep key sorting.
JSON to CSV
Flatten an array of objects into spreadsheet rows, quoted correctly.
CSV to JSON
Parse CSV — quotes, embedded commas, any delimiter — into JSON records.
JSON to YAML
Config-ready YAML with no folded strings and no anchors.
YAML to JSON
YAML 1.2 parsing, multi-document streams, errors reported by line.
JSON to XML
Arrays repeat their tag; @keys become attributes.
XML to JSON
Entities, CDATA, and namespaces handled by the browser’s XML parser.
JSON diff
Compare two documents by path — key order and indentation are ignored.