DevTools
All tools

JSON Formatter

Pretty-print or minify JSON and validate it, with error location.

What is the JSON Formatter / Minifier?

The JSON formatter takes JSON that's crammed onto one line or has messy indentation and pretty-prints it for readability, or does the reverse by stripping all whitespace to minify it to the smallest size. It's used to eyeball API responses, tidy up config files, or shrink JSON to reduce payload size.

Because the tool first validates input with the standard JSON.parse, it doubles as a validator. When there's a syntax error, it reports a message along with the approximate line and column where the problem occurred, so you can find a missing comma or a stray quote in large JSON far faster.

Pretty-printing uses 2-space indentation, and minifying removes every unnecessary space and line break. All processing happens entirely in your browser and the JSON you enter is never sent to a server, so it's safe to paste real API responses or configuration data.

How to use

  1. Paste the JSON you want to format or minify into the input box.
  2. Click 'Pretty' to expand it with 2-space indentation, or 'Minify' to produce single-line JSON with whitespace removed.
  3. Use the copy button to place the result on your clipboard. If there's a syntax error, the tool points to its location (line and column) so you can fix it and run again.

Frequently asked questions

When should I use 'Pretty' versus 'Minify'?
Pretty is useful when you need to read the structure while debugging or reviewing code. Minify is for reducing network payload or storage size, for example when embedding JSON on a single line in an environment variable or minimizing a response body.
Is the reported error line and column accurate?
The tool converts the position the browser's JSON.parse reports into a line and column. The actual problem is usually right around there, so scanning just before and after the marked spot makes it easy to spot a missing comma or an unclosed bracket.
Does it accept JSON with comments (//) or trailing commas?
No. This tool uses JSON.parse, which follows the strict JSON spec, so extensions like comments, trailing commas, and single-quoted strings (JSON5 or JSONC) are treated as errors. Clean it up to standard JSON first.
Does it change key order or number representation?
Key order is preserved as entered. However, numbers may be normalized per the JSON standard (e.g. 1.0 becomes 1, exponential notation is converted), and very large integers can lose precision. If precision matters, it's safer to handle those values as strings.