Skip to content
Tools

JSON Minifier (Compact JSON)

Last updated:

Minifying JSON removes every space, tab and line break between tokens, so the same data takes fewer bytes. Paste your JSON, press Ctrl/Cmd+Alt+M, and the size before and after is shown next to the single-line result.

Minification runs locally in your browser; your payload is not uploaded. How we protect your data

Input

Loading editor…

Paste JSON here

or drop a .json file anywhere in this box. Everything stays in your browser.

Output

Paste JSON to see it as a table.
Loading editor…
Paste JSON, drop a file, or try the sample.

How to use the json minifier

  1. Paste formatted JSON or upload a file.
  2. Press Minify or Ctrl/Cmd+Alt+M; invalid JSON is reported with its position instead.
  3. Check the byte count before and after.
  4. Optionally escape the result to embed it in a string or environment variable.
  5. Copy the single line with Ctrl/Cmd+Alt+C.

Features

  • Validate first: Broken input is never half-minified; you see the error and position.
  • Strings untouched: Spaces and newlines inside string values are preserved; only structural whitespace goes.
  • Size stats: UTF-8 bytes before and after, so the figure matches what goes over the wire.
  • Escape as JSON string: Turns the input into an escaped JSON string so it can sit inside another JSON value or a .env file; Unescape reverses it.

Example

Formatted (2 spaces, 69 bytes) → minified (47 bytes)

Input

{
  "user": "Ada Lovelace",
  "roles": [
    "admin",
    "dev"
  ]
}

Output

{"user":"Ada Lovelace","roles":["admin","dev"]}

A 32% saving. The space inside "Ada Lovelace" stays because it is part of the value.

Does minifying JSON actually help performance?

Over HTTP, most of the gain is already captured by gzip or Brotli, which compress repeated indentation very efficiently. Minifying a compressed API response typically saves only a small extra amount on the wire.

Minifying matters more where there is no compression: values stored in environment variables, database text columns, localStorage (with its roughly 5 MB per-origin budget), message queues with size caps, URL fragments, and fixtures bundled into JavaScript. It also slightly reduces parse time because the parser skips fewer characters.

Reducing JSON size beyond whitespace

Once whitespace is gone, the remaining size is your data. The biggest further savings usually come from dropping null or default fields, shortening repeated long key names, or sending arrays of rows instead of arrays of objects. Those change the data contract, so they belong in your code, not in a minifier.

Tips

  • Minify for storage and transport; keep the formatted version in source control so reviews stay readable.
  • Need a JSON value inside a shell variable? Minify, then use Escape so quotes do not break the command.
  • If a minified file still looks huge, check for base64 images or embedded HTML strings, which minification cannot shrink.

JSON Minifier FAQ

What does minifying JSON do?

It removes spaces, tabs and line breaks that sit between JSON tokens. The parsed data is identical; the text is shorter.

Is minified JSON still valid?

Yes. Whitespace between tokens is optional in JSON, so minified output parses to exactly the same value.

How much smaller does JSON get when minified?

It depends on nesting depth and indent width. Deeply nested, 4-space files shrink the most; the tool shows the exact saving for your input.

Should I minify JSON for APIs if I use gzip?

The wire saving is small because compression already removes most whitespace cost, but minifying still reduces uncompressed memory and parsing work. Many frameworks emit minified JSON by default.

How do I minify JSON in JavaScript?

JSON.stringify(JSON.parse(text)) produces minified output, but it rounds integers above 2^53. Use this tool or a lossless parser when IDs are large.

Can I un-minify JSON later?

Yes. Minification is fully reversible for the data; paste it into the beautifier to restore indentation.

Related tools