free tool · no sign-up · runs in your browser

JSON formatter and validator

Paste JSON to format it with 2 or 4 spaces or tabs, or minify it to one line. If it isn't valid, you'll see the line and column of the first error. Repair turns the near-JSON you copy out of JavaScript, config files and logs (comments, trailing commas, single quotes, unquoted keys) into valid JSON.

paste here

result

paste JSON to format it.

Free to embed. Put this json formatter on your blog, docs or class page.

The errors that make JSON invalid

InvalidValid
{"a": 1,}{"a": 1}
{'a': 1}{"a": 1}
{a: 1}{"a": 1}
{"a": 1 // note}{"a": 1}
{"a": undefined}{"a": null}
{"a": 1 "b": 2}{"a": 1, "b": 2}

Repair fixes the first four. The last two need a person: there's no safe guess for what undefined or a missing comma meant.

Format JSON from the command line

python3 -m json.tool data.json works on any Mac, and jq . data.json if you have jq. In JavaScript, JSON.stringify(value, null, 2) pretty-prints with 2 spaces.

JSON Formatter: questions

Why is my JSON invalid?+

The usual causes are a trailing comma after the last item, single quotes instead of double quotes, keys without quotes, comments, and a missing comma between items. JSON is stricter than JavaScript: none of those are allowed.

What does Repair do?+

It reads the text as JSON5, a looser format that allows comments, trailing commas, single-quoted strings and unquoted keys, and writes it back out as strict JSON. It won't guess at missing brackets or commas.

Should I indent JSON with 2 or 4 spaces?+

Either is valid. 2 spaces is the most common in JavaScript projects and APIs; 4 spaces is common in Python. Minify it when size matters, like in a request body or a URL.

Is my JSON uploaded?+

No. It's parsed by your browser, so API keys and customer data in it never leave the page.

More free tools