JSON Formatter and Validator
Format JSON for reading, minify it for shipping, and get a specific explanation when it fails to parse.
Free and instant — results appear in seconds. No sign-up, no limits, and nothing you type is stored.
JSON has a deliberately small grammar, and almost every parse failure comes from one of five violations of it. Trailing commas, single quotes, unquoted keys, comments, and NaN or Infinity are all valid JavaScript and none of them are valid JSON.
That gap is the source of most confusion. Code that works when pasted into a browser console fails when parsed as JSON, because the console is running a JavaScript engine with far looser rules.
Paste your JSON above to format or minify it. If it will not parse, the error message below names the specific violation rather than just reporting a syntax error.
The five failures, in order of frequency
Trailing comma. By far the most common:
{ "name": "Widget", "price": 19.99, }The comma after 19.99 promises another key that never arrives. JavaScript tolerates this; JSON does not. Same rule in arrays.
Single quotes. JSON requires double quotes for both keys and string values:
{ 'name': 'Widget' } ← invalid
{ "name": "Widget" } ← validUnquoted keys. Legal in a JavaScript object literal, not in JSON:
{ name: "Widget" } ← invalid
{ "name": "Widget" } ← validComments. There is no comment syntax in JSON at all. Neither // nor / /. If you need annotation, add a field named _comment — ugly, but valid.
Non-finite numbers. NaN, Infinity and -Infinity are JavaScript values with no JSON representation. Use null or a string.
A sixth that appears with copied data: unescaped control characters. A literal newline inside a string breaks parsing; it must be written as \n.
When minifying, the byte saving is usually 15 to 30 percent on indented data. Worth doing for API responses and config bundles; irrelevant for anything already compressed with GZIP, which handles repeated whitespace efficiently anyway.
What JSON permits
Six value types and nothing else: object, array, string, number, boolean, null.
No dates. A date in JSON is a string by convention, usually ISO 8601 (2025-08-03T14:30:00Z), and every parser hands it back as a string for your code to interpret.
No integers versus floats. There is one number type. Whether 1 becomes an int or a float is decided by the parser, not the format.
No comments, no trailing commas, no single quotes, no unquoted keys.
Large numbers lose precision
JSON numbers are typically parsed into IEEE 754 double-precision floats, which represent integers exactly only up to 2⁵³ − 1 (9,007,199,254,740,991).
Beyond that, precision is lost silently. A 64-bit database ID such as 9007199254740993 can come back as 9007199254740992 with no error raised anywhere. This bites people working with Twitter-style snowflake IDs and large database primary keys.
The standard remedy is to transmit such values as strings. Ugly, and correct.
Formatting or minifying, and when
Formatted JSON is for humans — reading an API response, editing a config file, reviewing a diff. Indentation makes structure visible and produces sane line-by-line diffs in version control.
Minified JSON is for transmission. Every byte of indentation is a byte over the wire.
In practice the distinction matters less than it used to, because GZIP compresses repeated whitespace very efficiently. Minifying an already-compressed response saves little. Config files committed to a repository should stay formatted; the diff quality is worth more than the bytes.
Duplicate keys are undefined behaviour
{ "id": 1, "id": 2 }The specification does not say what should happen. Most parsers keep the last occurrence, some keep the first, and a few raise an error. Do not rely on any of them.
Privacy
This tool parses input on the server to produce the result and stores nothing. If you are working with production credentials or personal data, prefer a local tool — jq on the command line, or your editor's built-in formatter — as a general habit with any online utility.
Frequently asked questions
Why does my JSON fail to parse when it looks fine?
Check for a trailing comma before a closing brace or bracket, single quotes instead of double, unquoted keys, or a comment. All four are valid JavaScript and none are valid JSON, which is why code that works in a browser console fails when parsed as JSON.
Can JSON have comments?
No. The format has no comment syntax of any kind. The usual workaround is a field named _comment or similar, which is valid JSON that your code ignores. Some supersets such as JSON5 and JSONC add comments, but standard parsers reject them.
Why did my large ID number change?
JSON numbers are usually parsed as double-precision floats, which represent integers exactly only up to 9,007,199,254,740,991. Larger values lose precision silently with no error. Transmit large IDs as strings instead.
Should I minify JSON in production?
It saves 15 to 30 percent on indented data, but GZIP compression already handles repeated whitespace efficiently, so the gain over a compressed connection is small. Minify API responses if you like; keep committed config files formatted, because readable diffs are worth more than the bytes.
How do I store dates in JSON?
As strings, since JSON has no date type. ISO 8601 in UTC — such as 2025-08-03T14:30:00Z — is the widely used convention. Every parser returns it as a string for your code to convert.
Is my data stored when I use this tool?
No. The input is parsed to produce the output and then discarded. As a general habit with any online utility, use a local tool such as jq or your editor's formatter when working with production credentials or personal data.
Reviews
No reviews yet. If this tool solved something for you, yours would be the first — and it helps other people decide whether it is worth their time.
