Developer tool

JSON Formatter

Format JSON, minify JSON, and spot syntax errors instantly.

JSON Formatter

Format, validate, and minify JSON in your browser.

All tools

Output

Related Tools

Continue the workflow with nearby developer and data utilities.

How To Use The JSON Formatter

Paste or type JSON into the input box, then press Format to indent it with clean two-space nesting, or Minify to strip every space and line break into a single compact line. The Copy button puts the result on your clipboard. If the text is not valid JSON, the status line tells you that parsing failed, so you can find and fix the problem before you use the data.

What Formatting, Validating, And Minifying Do

JSON (JavaScript Object Notation) is the standard format for API responses, configuration files, and data exchanged between services. Formatting (also called beautifying or pretty-printing) adds consistent indentation and line breaks so deeply nested objects and arrays become readable at a glance. Validating parses the text against the JSON specification and reports the first place it breaks. Minifying does the opposite of formatting: it removes every optional space and newline to shrink the payload, which saves bandwidth in production and space in storage.

Common JSON Errors And How To Fix Them

Most "invalid JSON" messages come from a handful of mistakes. JSON is stricter than a JavaScript object literal, so the rules below catch the great majority of parsing failures.

ProblemInvalidFix
Trailing comma{"a":1,}{"a":1}
Single quotes{'a':1}{"a":1}
Unquoted key{a:1}{"a":1}
Missing comma{"a":1 "b":2}{"a":1,"b":2}
Comment inside{"a":1 //note}{"a":1}

JSON keys must use double quotes, never single quotes, and the format allows neither comments nor trailing commas.

Worked Example: Minified Vs Formatted

A minified API response such as {"user":{"id":7,"roles":["admin","editor"]}} is compact but hard to scan. Formatting it expands each key onto its own indented line, so the structure of the user object and the roles array is obvious. When you finish reading or editing, minify it again before sending it back to the server so the payload stays small.

Why This Tool Is Useful

Reading raw API output, debugging a broken config file, or comparing two payloads is far easier when the JSON is properly indented. The formatter turns a single unreadable line into a clear tree, points to the spot where invalid JSON fails, and lets you switch back to a minified form for production, all without installing an editor extension or pasting sensitive data into an unknown server.

Accuracy And Privacy

Everything runs locally in your browser using the same JSON parser the browser uses, so the validation matches what your code will see, and nothing you paste is ever uploaded or stored. If validation fails, check for the issues in the table above: missing commas, trailing commas, single or unquoted keys, comments, or mismatched brackets are the usual causes.

FAQ

Does this tool upload my JSON anywhere?

No. Formatting, validation, and minifying all happen locally in your browser, so your data never leaves your device and is not sent to any server.

What is the difference between formatting and minifying?

Formatting adds indentation and line breaks to make JSON readable. Minifying removes all optional whitespace to make the file as small as possible for storage or transfer. The data itself is identical either way.

Why does my JSON say it is invalid?

The most common causes are a trailing comma before a closing bracket, single quotes instead of double quotes, unquoted keys, a missing comma between items, or comments, none of which are allowed in JSON. The status line shows where parsing failed.

Can JSON contain comments?

No. Unlike JavaScript, the JSON specification does not allow // or /* */ comments. Remove them before parsing, or use a format such as JSON5 or YAML if you need comments.

Is there a size limit?

There is no fixed limit, but very large files depend on your device's memory because everything is processed in the browser. Several megabytes of JSON format without trouble on a typical computer.