All tools

JSON Formatter

Pretty-print, validate, or minify JSON with helpful error positions.

  • json
  • pretty
  • minify
  • validate
  • lint

About JSON Formatter

JSON is the lingua franca of web APIs, configuration files, and data interchange — but in transit it usually arrives as a single dense line, which makes it nearly impossible to scan with the eye. Pretty-printing puts every key on its own line with consistent indentation; minifying does the reverse, stripping every byte of whitespace for compact storage or fewer bytes on the wire.

This formatter does both, plus validates the JSON in the process — if your input has a stray comma, a missing quote, or a duplicate brace, you get an error message with the line and column number pointing at exactly where the parser gave up. Everything runs in your browser, so even sensitive data never leaves the page.

How to use

Paste your JSON into the input field. If it's valid, the "Pretty" panel shows it formatted with your chosen indentation (2 spaces, 4 spaces, or tabs) and the "Minified" panel shows the single-line version, with a small note telling you how much smaller it is.

If it's not valid, the input border turns red and an error message appears with the line and column where parsing failed — handy for hunting down a missing comma or an unbalanced bracket in a large payload. Click "Load sample" if you just want to see what a formatted result looks like, and the copy buttons on each panel lift the result onto your clipboard.

Frequently asked questions

  • Is my JSON sent to a server?

    No. The parsing, formatting, and minifying all happen in your browser using the built-in JSON parser. Nothing leaves the page — safe to use for sensitive payloads like API tokens, customer records, or anything else that shouldn't leave your machine.

  • Why does JSON.parse complain about trailing commas?

    Because strict JSON, as defined by RFC 8259, doesn't allow them. JavaScript object literals do, and so does JSON5 — but standard JSON.parse rejects them. If your payload comes from a JavaScript file or a hand-edited config, strip any trailing commas before pasting.

  • Can I format very large JSON files?

    Yes, within the limits of your browser. The parser runs at native speed, so files up to several megabytes work fine on modern hardware. Beyond about 50 MB you may notice typing latency in the textarea — at that point a command-line tool like `jq` is more comfortable.

  • What's the difference between pretty-printing and minifying?

    Pretty-printing adds newlines and indentation so the structure is human-readable. Minifying does the opposite — strips every byte of whitespace for the smallest possible payload, which is useful for storage and reduces bytes on the wire. The two views show both forms side by side along with the size saving.

  • Why does the error message sometimes point at the wrong line?

    Because JavaScript's JSON.parse only reports a character position, not a structural error — and the converter back-translates that position into a line and column. The reported position is usually the first character the parser couldn't make sense of, but the actual mistake is often a few characters before (e.g. a missing closing quote earlier in the file).

More Text & Encoding tools