Skip to content
Daily Web Lab

JSON Formatter

Paste JSON to format or minify it instantly. If it will not parse, you get the exact line, column, and probable cause instead of a one-line complaint.

Press Ctrl+Enter (Cmd+Enter on Mac) to format.

Everything runs in your browser. Your JSON is never uploaded, logged, or stored.

How to Format JSONFormat JSON in your editor, from the terminal, or in code — and why the three formatters on your machine disagree with each other.

How to use the JSON Formatter

  1. Paste your JSON

    Drop it into the left panel. Validity is checked as you type, so you will see whether it parses before you do anything else.

  2. Choose indentation

    Two spaces, four spaces, or tabs. Turn on Sort keys if you want the output ordered alphabetically for easier diffing.

  3. Format or minify

    Format expands the JSON for reading; Minify strips whitespace for shipping. Ctrl+Enter (Cmd+Enter on Mac) formats without leaving the keyboard.

  4. Fix any error, then copy or download

    If parsing fails, the error panel points at the exact character. Once it parses, copy the result or download it as a .json file.

How to read a JSON syntax error

A JSON formatter has to parse before it can print, so when parsing fails it reports the first position it could not make sense of, which is not necessarily the position where the mistake was made. A missing closing brace on line 12 is usually reported at the end of the file, because that is where the parser finally runs out of input. So treat the reported line as the place to start reading, and look upward from there for the last structure that was left open.

1{
2 "user": {opened here
3 "name": "Ada",
4 "role": "admin"
5
6}error reported here
The brace opened on line 2 is never closed. The parser cannot know that until it reaches the end of the file, so it reports line 6, four lines below the actual mistake.

The error panel above gives you the line and column, the offending line with a marker under the exact character, and, where the cause can be identified with confidence, a plain description of what went wrong. The raw parser message is kept underneath, because it is occasionally more specific than any summary of it.

Mistakes that cause most failures

JSON is a deliberately small format. Nearly every syntax error comes from writing something that is valid in JavaScript, Python, or YAML but not in JSON itself:

Common JSON syntax mistakes and their corrections
What you wroteWhy it failsValid version
{"a": 1,}Trailing comma after the last item{"a": 1}
{'a': 1}Single quotes around a key{"a": 1}
{a: 1}Unquoted key{"a": 1}
{"a": None}Python literal instead of JSON{"a": null}
{"a": NaN}NaN and Infinity are not JSON values{"a": null}
{"a": 01}Leading zeros are not allowed{"a": 1}
{"a": .5}A number needs a digit before the point{"a": 0.5}
// note {"a": 1}JSON has no comment syntax{"a": 1}

One more that is hard to spot by eye: curly quotes. Text pasted out of a word processor or a chat client often has “smart” quotes substituted for straight ones. They look almost identical in a proportional font and JSON rejects them outright.

Formatting, minifying, and what neither one does

Formatting adds newlines and indentation so the structure is visible. Minifying JSON removes every byte of whitespace outside of strings, which is what you want before sending it over a network or storing it. The two are exact inverses, and running either one is lossless: the parsed data is identical, only its text representation changes.

What a JSON formatter does not do is repair anything. Invalid JSON cannot be formatted at all, because formatting requires parsing it first. Tools advertising a “JSON fixer” are guessing at your intent. That is fine for a quick look, and a poor idea for data you plan to keep. This tool reports the problem and leaves the correction to you.

The Sort keys option is the one setting here that changes the output beyond whitespace. Object key order carries no meaning in JSON, so sorting is safe, and it makes two versions of the same document directly comparable in a diff. Array order is never touched, because in an array the order is the data.

A gotcha worth knowing

Duplicate keys do not produce a syntax error. Given {"id": 1, "id": 2}, JavaScript’s parser silently keeps the last one, so this tool will format it without complaint and quietly return {"id": 2}. The JSON specification leaves this behaviour up to the implementation, and other languages resolve it differently: some keep the first, some raise an error, some return both. If a value seems to vanish during formatting, duplicate keys are the first thing to check.

Frequently asked questions

Is my JSON uploaded to a server?

No. Formatting, validating, and minifying all happen in your browser using its built-in JSON parser. Nothing is sent over the network, nothing is logged, and nothing is stored after you close the tab, so it is safe to use with configuration or data you would not paste into a hosted service.

What is the difference between formatting and validating JSON?

Validating JSON answers whether the text is legal JSON. Formatting rewrites valid JSON with consistent indentation so it is readable. In practice you get both at once here, because JSON has to be parsed successfully before it can be reformatted. If it formats, it was valid.

Why does my JSON fail when it looks correct?

The usual causes are invisible or nearly invisible in a proportional font: a trailing comma before a closing bracket, curly quotes pasted from a word processor, single quotes instead of double quotes, or an unquoted key. The error panel checks for each of these near the failure point and names the one it finds.

Does formatting change my data?

No. Only whitespace changes, so the parsed result is identical before and after. The one exception is the Sort keys option, which reorders object keys alphabetically. Key order carries no meaning in JSON, so that is still lossless, and array order is never changed.

Can this tool fix invalid JSON automatically?

No, and that is deliberate. Repairing broken JSON means guessing what the author meant, and a wrong guess produces data that looks fine but is subtly incorrect. This tool tells you exactly where the problem is and what likely caused it, and leaves the correction to you.

How large a file can I format?

The practical limit is your browser's available memory rather than a fixed size, since the whole document is held in the tab. Very large documents work, but validation stops running on every keystroke above roughly 100 KB to keep typing responsive. Press Format to check those explicitly.

Does it support JSON with comments, or JSON5?

No. Comments are not part of the JSON specification, so files using them are rejected, including .jsonc files and configuration formats that permit them. Strip the comments first, or use a parser built for that dialect.

The tools here run entirely in your browser and need no cookies. We would like to use cookies only for advertising and traffic measurement, which help keep the site free. Read our privacy policy.