JSON Formatter and Validator — JSON5 to JSON Online
Pretty-prints JSON with 2-space indentation and reports syntax errors with line and column. Input is parsed as JSON5, so comments, single quotes, unquoted keys and trailing commas are accepted; the output is always strict JSON.
Reading a minified API response that arrives as a single line.
Accepts JSON and JSON5, including comments, single quotes and trailing commas. Functions and JavaScript expressions are not executed.
JSON / JSON5 input
Formatted JSON
When to use it
- Reading a minified API response that arrives as a single line.
- Turning a commented JSON5 or tsconfig-style file into strict JSON for a tool that rejects comments.
How to use
- Paste JSON or JSON5 into the left editor, or load a .json file.
- If an error appears, go to the reported line and column and check quotes, brackets and commas.
- Copy the indented strict JSON from the right editor.
JSON or JSON5 input
// service config
{
name: 'billing-api',
port: 8080,
retries: [1, 2, 4,],
debug: false,
}Formatted JSON
{
"name": "billing-api",
"port": 8080,
"retries": [
1,
2,
4
],
"debug": false
}Details and limitations
Formatting runs in your browser; nothing is posted to a server.
Comments and the original quoting style are dropped. Indentation is fixed at 2 spaces; there is no minify or sort-keys option on this page.
Values are parsed as data only, never executed. NaN and Infinity are rejected because JSON cannot represent them.
Duplicate keys do not raise an error: the last value wins, so {"a":1,"a":2} becomes {"a": 2}.
FAQ
Can it format JSON that contains comments?
Yes. // and /* */ comments are accepted because the input is read as JSON5, but they are removed from the output, which is strict JSON.
Why did my large integer change?
Numbers become JavaScript doubles, so integers beyond 2^53 lose precision: 12345678901234567890 is printed as 12345678901234567000. Quote long IDs as strings.
Does it validate against a JSON Schema?
No. It only checks syntax. Required fields, types and value ranges defined by a schema are not checked.