JSON Formatter
Format keeps comments and trailing commas. Minify removes both and outputs strict JSON. The status line lists each error's line, column, parser error name and a context excerpt.
About this tool
Paste JSON or JSONC. Format re-indents the original text with
jsonc.format, so comments and trailing commas survive. Minify
parses the value and runs it through JSON.stringify on one
line, which removes both.
How to use
- Paste JSON or JSONC into Input.
- Leave Minify off to keep comments and trailing commas, or check it to produce strict JSON on one line.
- Output updates as you type. The status line lists the line, column, parser error name and a short context excerpt for each syntax error; a partial result is still shown when the input is incomplete.
What it does not do
Minify parses and re-serialises, so the original text is not preserved. Format edits whitespace only.
-
Minify loses large-integer precision. JSON numbers
become IEEE-754 doubles, so
9007199254740993becomes9007199254740992. Keep 64-bit identifiers as strings. Format leaves the digits alone. - Minify keeps only the last duplicate key, without a warning. Format keeps both.
- Minify drops comments and trailing commas. Format keeps them, so its output is JSONC when they are present.
Example
Input: {
// keep me
"a": 1,
"b": [true, null,],
}
Format: {
// keep me
"a": 1,
"b": [
true,
null,
]
}
Minify: {"a":1,"b":[true,null]}
Limits
-
JSON5-only syntax is still rejected: single-quoted strings, unquoted
keys, hexadecimal numbers,
NaN,Infinityand leading+signs. -
The parser is loaded from
cdn.jsdelivr.netwhen the page opens. The page cannot format without a network connection. - Very large documents are processed synchronously, so the tab can pause while it works.
-
Input and output are written to
localStorageon every change, so a payload of several megabytes can exceed the storage quota.
FAQ
Are comments and trailing commas preserved?
Yes when Minify is off: Format re-indents the original text, so both survive. Minify parses and re-serialises, which removes them.
Why is the output shown even when the input has errors?
jsonc-parser is fault tolerant: it records each error and still returns the value it could read. The status line lists the line, column, parser error name and a short context excerpt for each error; Output shows that partial value.
Does Minify change values?
It can. Parsing turns numbers into JavaScript doubles and objects into plain objects, so large integers lose precision and duplicate keys keep the last value. Comments and trailing commas are dropped. Format edits whitespace only and leaves values alone.
Is my JSON uploaded?
The text is not uploaded. The page does load the jsonc-parser script
from cdn.jsdelivr.net, so that CDN receives a request for
the script file and your IP address.
Further reading
Common JSON syntax errors lists the eight mistakes that make the parser fail, plus the valid JSON that still surprises people.