Pixel and Prose

JSON Formatter: format, minify and validate

Updated
Cover image for "JSON Formatter: format, minify and validate" – Pixel and Prose

Paste JSON to format it with clean indentation, minify it to one line, or check it for errors. Invalid JSON is flagged with the line and column of the problem, so you can fix it fast.

Formatting happens in your browser. Your JSON is never uploaded: API responses or config files with private data stay in this browser tab and are not sent to a server.

How to use the JSON formatter

  1. Paste your JSON into the box, or type it.
  2. Click Format to pretty-print it with the indent you choose, or Minify to strip all spaces and line breaks.JSON Formatter showing a one-line JSON object formatted with two-space indentation
  3. If the JSON is invalid, a message shows the line and column where parsing stopped, and the cursor jumps there.
  4. Copy the result or download it as a .json file.
JSON Formatter error message: invalid JSON at line 3, column 30, caused by a trailing comma

Common JSON errors

ProblemWrongRight
Trailing comma[1, 2, ][1, 2]
Single quotes{'a': 1}{"a": 1}
Unquoted key{a: 1}{"a": 1}
Comments// noteNot allowed in JSON
Special valuesNaN, undefinednull or a number

To rename keys for code, the case converter turns text into camelCase or snake_case. For a random token or test password, use the password generator.

Laptop with an illuminated keyboard, with text of three common JSON mistakes

Frequently asked questions

Does formatting change my data?

No. Only the spaces, tabs and line breaks between values change. Keys, values and their order stay exactly as you typed them, including how numbers and escapes are written (1.50 stays 1.50, 1e3 stays 1e3, very long numbers keep every digit, \u00e9 stays \u00e9), unless you tick "Sort keys A to Z". If an object has the same key twice, both copies are kept and the tool warns you, because many programs keep only the last one.

What is the difference between formatting and minifying?

Formatting adds line breaks and indentation so people can read the structure. Minifying removes every unnecessary space and line break, which makes the file smaller for sending over a network or storing in code.

Can it handle large files?

Files of several megabytes work in a modern desktop browser. Very large files may be slow on phones because the whole text is processed in memory.

Does it support JSON with comments (JSONC or JSON5)?

No. The tool follows the strict JSON standard, so comments, trailing commas and single quotes are reported as errors. That is useful when your file must be valid for an API or a strict parser.