Paste JSON to pretty-print, minify, or validate it. Everything runs in your browser.
Status
Paste JSON, then pick an action.
Output
—
Frequently asked questions
- Does this validate as well as format?
- Yes. The tool parses your input with the same engine the browser uses, so any syntax error is reported with its message. If it parses, you can pretty-print it with a 2-space, 4-space, or tab indent, or minify it to a single line. All processing happens in your browser.
- What is the difference between pretty-print and minify?
- Pretty-printing adds indentation and newlines to make the structure readable. Minifying removes all unnecessary whitespace and produces the shortest possible string, which is useful when transmitting JSON over a network to reduce payload size. Both produce semantically identical JSON.
- When should I use a tab indent rather than spaces?
- Tab indentation is a common style in some codebases and tools because each tab character is a single byte and editors can display it at any width. Spaces are more portable across editors that render tabs differently. The choice is a matter of your team or project style guide. The tool supports 2 spaces, 4 spaces, or a tab so you can match whichever convention your project uses.
- Why does the formatter report a syntax error on my JSON?
- Common causes include trailing commas after the last item in an object or array, single-quoted strings instead of double-quoted strings, unquoted keys, and JavaScript-style comments. These are valid in JavaScript but not in strict JSON. The error message from the browser parser usually identifies the character position of the problem.
Related calculators
Embed this calculator on your site (free)
Paste this code into your page. The calculator stays up to date automatically and links back to PennyCompass.