JSON formatter and validator
- Runs in your browser
- No signup
- Formula shown below
- Reviewed
A JSON formatter parses a JSON document and re-prints it with consistent indentation, reporting the line and column of any syntax error. Minifying removes all insignificant whitespace, which typically cuts a formatted payload by 15 to 30%. This formatter runs in the browser, so production payloads containing tokens are never transmitted.
How to use the JSON formatter
- 01
Paste your JSON
Paste or type the document into the input pane. Formatting and validation run as you type, with no button to press.
- 02
Check for errors
If the document is invalid, the error message names the problem and gives the line and column where the parser stopped.
- 03
Choose your output style
Select 2, 4 or 8-space indentation, switch on minify to strip all whitespace, or sort keys alphabetically to compare two documents.
- 04
Copy or download
Copy the formatted output to the clipboard or download it as a .json file. Nothing was transmitted at any point.
The formula
JSON.parse(text) → value → JSON.stringify(value, null, indent)
- JSON.parse
- The native parser, which either returns a value or throws with a byte offset for the first syntax error.
- value
- The resulting JavaScript value — an object, array, string, number, boolean or null.
- indent
- Spaces per nesting level when pretty-printing. Passing no indent produces minified output.
- depth
- The deepest level of nesting in the document, reported alongside key, object and array counts.
Round-tripping through parse and stringify normalises the document: key order is preserved but whitespace, number formatting and string escapes are rewritten canonically. That is why 1.0 comes back as 1 and \u0041 comes back as A — both are the same JSON value, written differently.
Worked example
- Input
- {"name":"TrueScalers","tools":27,"meta":{"reviewed":"2026-08-09"}}
- Indent
- 2 spaces
- Minify
- off
- Result
- Valid JSON — 3 keys, 2 objects, 2 levels deep
The parser reads the 66-character input and produces an object with 2 top-level keys plus 1 nested key, giving 3 keys across 2 objects and no arrays. Re-printing with 2-space indentation expands it to 6 lines and about 110 bytes, because each nesting level adds whitespace. Minifying the same value returns it to 66 bytes, a 40% reduction — which is exactly why APIs send minified JSON and developers read formatted JSON.
Frequently asked questions
How do you find a syntax error in JSON?
The parser reports the byte offset where it stopped, which is converted here into a line and column number. The most common causes are a trailing comma after the last element, a single quote used instead of a double quote, an unquoted key, and an unescaped newline inside a string. The reported position is where parsing failed, which is sometimes just after the real mistake.
What is the difference between formatting and minifying JSON?
Formatting adds newlines and indentation so a human can read the structure. Minifying removes every byte of insignificant whitespace so a machine can transfer it efficiently, typically cutting 15 to 30% from a formatted document. Both represent exactly the same value, so an API can send minified JSON and a developer can read the formatted form.
Are comments allowed in JSON?
No. RFC 8259 defines no comment syntax, and a standard parser rejects any document containing one. Supersets such as JSON5 and JSONC add comments and are used in configuration files including tsconfig.json, but they are not JSON and will not parse here. Strip comments before validating against the standard.
Why does sorting JSON keys matter?
Object key order is not semantically meaningful in JSON, but a textual diff treats reordered keys as changes. Sorting both documents alphabetically before comparing makes a diff show only genuine differences. Sorting also produces a canonical form, which is useful when hashing a payload to detect whether its content has actually changed.
Is it safe to paste API responses into this tool?
Yes. Parsing and formatting happen entirely in this page using the browser's native JSON implementation, and this site has no server-side code capable of receiving text. Nothing is transmitted, logged or stored, so a payload containing an access token or customer data is no more exposed than in a local text editor.
Why did my large numbers change after formatting?
JSON numbers are parsed into IEEE 754 double-precision floats, which represent integers exactly only up to 2⁵³ − 1, or 9,007,199,254,740,991. A 19-digit database identifier exceeds that and is silently rounded. Systems that must preserve such values transmit them as strings, which is why many APIs quote their ID fields.
Sources
- RFC 8259 — The JavaScript Object Notation (JSON) Data Interchange Format — IETF
- ECMA-404 — The JSON Data Interchange Syntax — Ecma International
- IEEE 754 double-precision and safe integers — Mozilla Developer Network
Last reviewed: · Formula and sources verified by Syed Aqeel Ahmad Gillani. See the methodology for how every calculation is derived.