PrettyJSON Logo
PrettyJSON

Instantly clean, validate, and inspect web payloads

Sample Payloads
Buy me a coffee
Raw JSON Input

Waiting for JSON content

Start typing on the left or load one of the sample payloads to inspect it instantly.

RFC 8259 Compliant & 100% Client-Side

JSON Minifier Online — Compress & Minify JSON

Compress and minify JSON payloads online instantly onto a single line. Calculate real-time bandwidth savings and optimize API transmission sizes for production.

Private & Offline Ready

Every tool runs in your browser, so the JSON you paste never leaves your device.

Works Instantly, Even Offline

Formatting, minifying, repairing, and the tree view all run on your device, so there are no uploads to wait on.

Exact Error Line & Column

Syntax errors like unescaped quotes and trailing commas are flagged with their exact line and column.

How JSON Minification Works and When to Use It

What gets removed, how much smaller the payload gets, and where a minifier fits in a real workflow.

1. What Minifying Removes (and How Much Smaller It Gets)

Minifying JSON removes the characters that exist only for human readability — the line breaks, indentation, and the spaces after colons and commas. The data itself is untouched. How much you save depends on how much whitespace was there to begin with: a heavily indented file can shrink noticeably, while an already-compact payload barely changes. The saving is simply the whitespace you remove as a share of the original size. On its own that helps, and when your server also applies gzip or Brotli compression, minified JSON compresses a little further.

Formatted vs Minified JSON
// Formatted (112 bytes)
{
  "id": 101,
  "status": "active",
  "roles": [
    "admin",
    "developer"
  ]
}

// Minified (52 bytes)
{"id":101,"status":"active","roles":["admin","developer"]}
Explanation: Line breaks and indentation are removed; every key, value, and data type stays exactly the same.

2. Keeping Strings Intact While Stripping Whitespace

The one thing a minifier must never do is remove spaces that are inside string values — turning "John Smith" into "JohnSmith" would corrupt your data. PrettyJSON handles this by tracking whether it is currently inside a quoted string as it scans the text, so spaces inside strings are preserved while the structural whitespace around braces, brackets, colons, and commas is removed. Escaped quotes inside strings are handled correctly, so the output is always valid JSON with identical data.

Technical Highlights

  • Spaces inside string values are always preserved.
  • Only the structural whitespace between tokens is removed.
  • Escaped quotes inside strings are handled correctly.

3. Where Minifying Fits in a Workflow

Minified JSON is mainly useful when size matters: API responses, config bundled into a build, data cached in memory, or messages sent over a network. Smaller payloads mean a little less to transfer and store. A common pattern is to keep JSON readable in source control and minify it as part of a build or deploy step, so humans work with the formatted version and machines get the compact one. Because PrettyJSON runs in your browser, you can minify sensitive payloads without sending them anywhere.

Technical Highlights

  • Useful for API responses, build bundles, caches, and network messages.
  • A common pattern: keep JSON readable in source, minify at build time.
  • Runs locally, so sensitive data is not uploaded.

Frequently Asked Questions

Common questions and expert answers regarding this tool.

What is JSON Minification?

Minifying removes the whitespace that exists for readability — line breaks, indentation, and spaces between tokens — and puts the JSON on a single line. The data stays the same.

How much smaller does minifying make JSON?

It depends entirely on how much whitespace the original had. A heavily indented file shrinks more; an already-compact one barely changes. The saving is the whitespace you remove as a share of the original size.

Does minifying JSON change my data?

No. Only whitespace outside of string values is removed. Keys, values, data types, and the spaces inside strings are all preserved.