Tools Guides
developer Free No signup

JSON Minifier & Beautifier

Format JSON with syntax highlighting or strip whitespace to minify — with real-time validation and size stats.

Loading tool…

About this tool

Toggle between Beautify and Minify modes: Beautify formats your JSON with 2 or 4-space indentation and color-coded syntax highlighting; Minify removes all unnecessary whitespace for production payloads. Conversion happens in real time as you type. The tool reports the original size, output size, and percentage change, and any JSON errors are flagged with an exact line and column number.

How to use

  1. 1 Paste or type your JSON into the left input panel.
  2. 2 Click 'Beautify' to format with indentation and syntax highlighting, or 'Minify' to strip whitespace.
  3. 3 Check the size stats bar to see the original size, output size, and percentage change.
  4. 4 If there are errors, read the line/column hint in the error banner and fix the JSON in the input panel.

What minification actually removes

JSON minification is the process of stripping every byte that a parser does not need. Human-readable JSON is padded with whitespace for our benefit: line breaks after each property, two or four spaces of indentation per nesting level, and a space after every colon and comma. None of that affects the data. A minifier parses the JSON into a real object and then re-serialises it with zero formatting, so { "name": "Alice", "age": 30 } spread across several indented lines collapses to the single string {"name":"Alice","age":30}. The values are byte-for-byte identical; only the cosmetic spacing is gone.

This tool does both directions. Minify produces the compact form. Beautify does the reverse — re-indenting with your choice of 2 or 4 spaces and syntax-highlighting keys, strings, numbers, and literals — for when you receive a dense blob and need to read it.

Where the savings come from — a worked example

Indentation is the biggest source of bloat, and it compounds with depth. Consider a config with nested objects:

{
  "server": {
    "host": "localhost",
    "port": 8080
  }
}

That pretty version is 64 bytes. Minified, it becomes {"server":{"host":"localhost","port":8080}} — 43 bytes, a 33% reduction. The tool measures this for you: after each operation a stats line shows input size, output size, and the percentage change. Minifying turns the percentage green and negative (smaller); beautifying turns it red and positive (larger), because re-adding indentation grows the file. The byte counts use UTF-8 encoding, so multi-byte characters are counted accurately rather than as one byte each.

FormBytes (example)Use it for
Pretty, 4-spaceLargestReading, code review, diffs
Pretty, 2-spaceMediumA compromise for committed config files
MinifiedSmallestNetwork transfer, storage, embedding

Why minified JSON matters in production

On a busy API, those saved bytes repeat on every single request. Trimming 20–40% off each JSON response reduces bandwidth costs and shortens transfer time, which is felt most on mobile connections. Minified JSON is the right form for anything that travels over the wire or gets stored at scale: API payloads, data embedded in HTML, records in a cache or database column, and configuration shipped inside a bundle. In real deployments minified JSON is then usually compressed with gzip or brotli on top, and the two stack — minification removes structural whitespace, compression removes statistical redundancy.

Practical tips

  • Minify for machines, beautify for humans. Commit and ship the compact form; expand it only when you need to read or debug it. This tool lets you flip between the two instantly.
  • Validate while you minify. Because the tool parses before re-serialising, invalid JSON cannot be minified — a malformed input is caught here, which doubles the tool as a quick syntax check.
  • Use the error location. When parsing fails, the banner reports the line and column of the problem (derived from the parser's character position), so you can jump straight to the stray comma or unquoted key.
  • Pick 2-space for diffs. If the JSON lives in version control, 2-space beautified output keeps line diffs readable while staying smaller than 4-space.

Common mistakes

  • Expecting key names or values to shrink. Minification only removes whitespace; it never renames keys or alters data. The string "description" stays exactly that. If you need smaller keys, that is a schema change, not minification.
  • Trying to minify JSON with comments or trailing commas. Standard JSON allows neither. A trailing comma or a // comment will fail parsing — strip those first.
  • Assuming minified JSON is unreadable forever. It is fully reversible. Paste any compact JSON back in and Beautify restores readable, highlighted formatting with no data loss.
  • Worrying about precision. Re-serialising can normalise number formatting (for example, dropping a redundant trailing zero), but the numeric value is preserved.

Everything runs in your browser

Your JSON is parsed and re-serialised entirely on your own device using the browser's native JSON engine — nothing is uploaded, logged, or stored on a server. That makes it safe to minify configuration containing internal hostnames, tokens, or proprietary data. You can confirm it by going offline: both Minify and Beautify keep working, because there is no network step involved.

Frequently Asked Questions

{# Alpine.js — self-hosted. (The previous jsdelivr CDN tag had a stale SRI integrity hash, so the browser refused to run it and window.Alpine was never defined — silently breaking every FAQ accordion and Alpine tool.) #}