Developer & Tech
JSON Formatter & Validator
Enter your details
Runs in your browser
How to use it
Using the json formatter & validator
- 01
Paste your JSON
Raw API responses, config snippets, anything syntactically JSON.
- 02
Choose pretty or minify
Pretty for reading and diffs; minify for embedding in payloads.
- 03
Fix errors by position
If validation fails, jump to the character position named in the error message.
Good to know
Formatting never changes data
Whitespace is not data in JSON. Pretty-printing and minifying both round-trip losslessly; the parsed value is identical before and after, which makes formatting safe on production payloads.
Reading V8 error positions
When validation fails, the message quotes the offset where the parser gave up. For a stray trailing comma that position lands just past it, so scanning backwards one or two characters almost always finds the culprit.
What JSON rejects but JS allows
- Comments; none exist in JSON despite looking like JavaScript
- Single-quoted strings; double quotes only
- Trailing commas; hard error
- NaN / Infinity / undefined; not representable
How it's calculated
The math behind this calculator
output = JSON.parse(input) then JSON.stringify(parsed, null, indent | undefined)The input is parsed with the same strict JSON grammar browsers use. Valid input is re-serialized either with your chosen indentation or with all insignificant whitespace stripped for minified output.
On failure, the engine’s own syntax-error message is surfaced verbatim, including the character position where parsing stopped; usually pointing at the offending comma, quote or brace.
Assumptions & limitations
- Duplicate object keys are legal but only the last value survives parsing.
- Trailing commas, comments and single quotes are invalid JSON and will be rejected.
- Very large inputs may be slow; parsing is linear in input size.
Worked example
The compact object {"a":1,"b":[2,3]} pretty-printed at two-space indent becomes a readable five-line document.
FAQ
Frequently asked questions
- Is my JSON sent anywhere?
- No. Parsing and formatting happen entirely in your browser via JavaScript’s built-in JSON engine; nothing leaves the page.
- Why does my config file fail here but work in my build tool?
- Many tools accept JSONC (comments) or trailing commas. This validator enforces strict RFC 8259 JSON; strip comments and trailing commas first.
- Does pretty printing sort keys?
- No. Object key order from JSON.parse is preserved as-is; sorting would change semantics for some consumers.
- Can I format huge files?
- Megabyte-scale documents work fine; multi-hundred-megabyte dumps may hit browser memory limits.
Keep exploring