Text
JSON Formatter
Format, minify, and validate JSON. Choose an indent level to pretty-print for readability, or compress to a single line. Syntax errors are highlighted instantly.
JSON Input
Formatted Output
Valid JSON
Invalid JSON
{{ result.lines }} lines / {{ result.bytes.toLocaleString() }} bytes
{{ result.error }}
Tips
- JSON keys must always be wrapped in double quotes. Single quotes are not valid.
- Trailing commas (
{"a":1,}) are invalid per the JSON specification. - Numbers in e-notation are valid. However,
NaNandInfinityare not. - Double quotes inside strings must be escaped as
\". Use\nfor newlines and\tfor tabs. - Minification is useful for reducing file size. Use the minified version for API transfers and the formatted version for config files.
Frequently Asked Questions
In JSON, keys must always be double-quoted, trailing commas are not allowed, and
undefined, functions, NaN, and Infinity cannot be used.No. The JSON specification has no comment syntax. JSON5 and JSONC are used as alternatives that support comments.
RFC 8259 mandates UTF-8. UTF-8 is strongly recommended for interoperability.
The JSON specification treats all numbers as a single
number type. Large integers may lose precision in JavaScript if they exceed MAX_SAFE_INTEGER.Side Note — Why JSON Won Over XML
In the early 2000s, XML was the dominant data format. In 2001, Douglas Crockford proposed JSON as a lighter, more approachable, and more readable alternative. By the 2010s, JSON had become the standard.
For the same data, JSON is often 30–50% smaller in byte count than XML — a difference that directly translated to faster app response times in the era of mobile data connections.
RFC 8259 states that duplicate keys are "SHOULD NOT" — not prohibited. {"a":1,"a":2} is syntactically valid, but its behavior is undefined.