JSON Formatter
Validate and pretty print JSON with this JSON Formatter. Paste compact or minified JSON and the tool checks it against strict JSON rules, then indents objects and arrays with two spaces, keeps short values that fit in 80 columns on one line and preserves key order, strings and number precision. Invalid JSON gets a clear error instead. Ideal for developers reading API responses, config files and logs.
Frequently asked questions
What does the JSON Formatter do?
It first checks that your input is valid JSON and then prints it with two space indentation. Objects and arrays that fit within 80 columns, such as short lists of tags, stay on a single line.
What happens with invalid JSON?
The tool stops with an error message such as Syntax error instead of guessing. Trailing commas, comments, single quotes and unquoted keys are not valid JSON; use the JSON Repair tool to fix them first.
Does it change the order of keys?
No, keys stay in the order you entered them, and duplicate keys are kept as they are. Only whitespace and line breaks change.
Are numbers changed?
Numbers are copied as written, so precision and large integers are preserved. Only exponents are normalized: 1E+5 becomes 1e5 and -0.5e-03 becomes -0.5e-3.
Are Unicode escapes decoded?
No, strings are copied exactly, so escapes such as \u00e9 stay escaped and literal characters stay literal. Quotes and backslashes inside strings are never touched.
Is there a nesting limit?
Yes, documents nested deeper than 512 levels are rejected. Real API responses and configuration files stay far below that limit.
Can I format an empty input or a single value?
An empty input is not valid JSON and returns an error. A single value such as a string, a number, true or null is valid and is returned unchanged.
Can I choose tabs or four spaces?
No, the formatter always indents with two spaces and has no options. Most editors can convert the indentation afterward if your project uses tabs.
Why is the result wrapped in a json code fence?
The output is returned as a Markdown code block marked json, so it renders highlighted in Markdown, issues and chat. Copy the lines between the fences for a .json file.
How large can my JSON be?
Up to 5 MB per run; larger input is rejected with a message. The output is identical to the JSON option of the Code Formatter.