JSON Formatter / Validator
Validate raw JSON and pretty-print it with your choice of indentation.
Formatted JSON will appear here.
What This Tool Does
This tool checks whether a block of JSON text is actually valid JSON, and if it is, rewrites it as clean, consistently indented, human-readable text. It's built for two situations: sanity-checking JSON before you use it somewhere (an API response, a config file, a payload you're debugging), and turning minified or inconsistently formatted JSON into something you can actually read.
How to Use It
Paste your JSON into the input box, pick an indentation style — 2 spaces, 4 spaces, or Tab — and click Format & Validate. If the JSON is valid, the formatted result appears below with a Copy button. If it isn't, you'll get a specific error message rather than a silent failure, including the approximate line and column where the parser gave up whenever that information is available.
The Formula
Validation runs through the browser's own JSON.parse, the same strict parser every JavaScript environment uses — if it accepts your input, the input is genuinely valid JSON, not just JSON-like. The Indentation dropdown maps directly to JSON.stringify's own indent argument: 2 or 4 inserts that many space characters per nesting level, and Tab inserts a literal tab character instead. All processing happens locally in your browser — nothing you paste is sent anywhere.
A Worked Example
Paste in a minified object like {"name":"Alice","age":30,"tags":["admin","active"]} and click Format & Validate — the output expands to one property per line, with the nested array's entries each on their own line too. Now try pasting the same object with a trailing comma, like {"name":"Alice","age":30,}— instead of formatted output, you'll get a clear error naming the problem and roughly where it is in the text, so you know exactly what to fix.
Common JSON Errors
Most invalid JSON comes from a small handful of habits carried over from JavaScript, where these are all perfectly legal but JSON is stricter:
- Trailing commas. {"a": 1, "b": 2,} is valid in a JavaScript object literal but invalid JSON — remove the comma after the last item in an object or array.
- Single quotes instead of double quotes. {'a': 1} fails because JSON requires double quotes around every string and every key, with no exceptions.
- Unquoted keys. {a: 1} is common JavaScript shorthand, but JSON requires every object key to be a double-quoted string: {"a": 1}.
- Using
undefined. JSON has no concept ofundefined— it only supportsnullfor an absent value. {"a": undefined} will always fail; use {"a": null} instead.
FAQ
- Does this tool validate JSON, or just format it?
- Both. It parses your input with a strict JSON parser first — if it fails, you get a clear error with the approximate line and column, and no formatted output is shown.
- Is my JSON sent to a server?
- No, all validation and formatting happens directly in your browser. Your data never leaves your device.
- Why does my JSON fail even though it looks correct?
- The most common causes are trailing commas, single quotes instead of double quotes, unquoted object keys, or using `undefined` instead of `null` — see the Common JSON Errors section above for details.