Text 🔒 Runs in your browser — no data sent to servers

JSON Minifier

Strip whitespace from JSON and get a compact, valid single line, minified as you paste.

Input JSON

Minify JSON Online

Pretty-printed JSON is written for people; the indentation and line breaks mean nothing to a parser. Minifying removes them so the same data takes fewer bytes and fits on one line, which is handy for environment variables, command-line arguments, log lines and request bodies.

This page opens the JSON Formatter set to minify as soon as you paste. The document is parsed first, so you only ever copy valid JSON.

Diagram: the same JSON object on one line (35 bytes) and formatted with a two-space indent (61 bytes).Minified: 35 bytes{"id":7,"tags":["a","b"],"ok":true}FormatMinifyFormatted: 61 bytes{"id": 7,"tags": ["a","b"],"ok": true}
Formatting only adds whitespace: line breaks and indentation. The data is identical in both versions, which is why minifying can strip it again for the network without changing what the JSON means.

What exactly is removed

  • Indentation spaces and tabs.
  • Line breaks between keys and array items.
  • Spaces after : and ,.
  • Nothing inside quoted strings: "New York" keeps its space.

When minifying helps

SituationWhy one line helps
Environment variables and secrets managersMany expect a single-line value
curl and CLI argumentsNo escaping of line breaks in the shell
Structured logs (JSON Lines)One record per line is the format
Storing JSON in a database columnFewer bytes per row
Static JSON files served by a websiteSmaller downloads, even before compression

Minify versus gzip

For JSON served over HTTP, compression does most of the work: gzip and Brotli are very good at squeezing repeated whitespace. Minifying still helps a little and costs nothing, but do not expect a 40 percent smaller text to mean a 40 percent faster response. Where minifying clearly wins is anywhere compression is not applied, such as local storage, database fields and message queues.

Minifying in code

  • JavaScript: JSON.stringify(JSON.parse(text))
  • Python: json.dumps(obj, separators=(',', ':'))
  • jq: jq -c . file.json
  • PHP: json_encode(json_decode($text))

Need to find a syntax error first? JSON Validator explains what is wrong and where.

Guides