billsvip

Json Minify

Paste JSON to minify it instantly: all unnecessary spaces, tabs and line breaks are removed while the data stays exactly the same. The tool validates the JSON, shows the original and minified size in bytes and the percentage saved, and can sort keys or pretty-print the result.

JSON minifier

JSON & API Developer Reference Sheets

Printable JSON syntax cheat sheet, HTTP status code reference, REST API design checklist and a JSON data contract template.

Formats: PDF, XLSX, DOCX. Instant download after payment (link valid 72 hours, up to 5 downloads). AI-assisted: the templates were drafted with AI help and reviewed and laid out by Kedop.

$3.00 USD, one-time

Secure card checkout by Stripe. Full refund within 7 days — see the refund policy and license.

What JSON minification does

JSON allows any amount of whitespace — spaces, tabs and line breaks — between tokens, which makes it readable for people. Computers do not need it. Minifying removes all of that insignificant whitespace, leaving the same data in the smallest text form. Whitespace inside string values is kept, because it is part of the data. The minified output parses to exactly the same object as the original.

How much space does minifying save?

Savings depend on how the JSON was formatted. Deeply nested, indented JSON with four-space indentation often shrinks by 20–40%; JSON with long string values shrinks less. In the example above, the pretty-printed product record is about 250 bytes and the minified version about 160 bytes — roughly 35% smaller. Over an API that returns thousands of records per minute, or a configuration file shipped with every page load, those bytes add up.

Minify vs compress

TechniqueWhat it doesTypical use
MinificationRemoves whitespace from the textStored files, embedded JSON, logs
Gzip / Brotli compressionCompresses the bytes during transferHTTP responses — enable on your server or CDN
BothMinify, then compressLargest savings for static JSON files

HTTP compression usually saves far more than minification alone because JSON is very repetitive, and compressed pretty-printed JSON is only slightly larger than compressed minified JSON. Minification still helps where compression is not applied, such as JSON stored in databases, localStorage, URLs or embedded in HTML.

Options explained

How to minify JSON in code

In JavaScript, JSON.stringify(value) produces minified JSON and JSON.stringify(value, null, 2) pretty-prints it. In Python, json.dumps(value, separators=(",", ":")) gives the most compact output, while json.dumps(value, indent=2) pretty-prints. On the command line, jq -c . minifies and jq . pretty-prints. Most languages’ JSON libraries have similar options.

Validating JSON

ErrorCause
Unexpected tokenTrailing comma, single quotes, or a comment
Unexpected end of JSON inputMissing closing bracket or brace
Bad control characterUnescaped newline or tab inside a string
Unexpected numberLeading zeros such as 007, or a number where a key should be

The minifier reports the error and the line where parsing failed. Fix the input and the output updates as you type.

Worked example

A mobile app embeds a 48 KB pretty-printed JSON configuration file with four-space indentation. Minifying it removes about 17 KB of whitespace, leaving 31 KB. With gzip compression on the server, the transferred size drops from about 7 KB (pretty) to about 6 KB (minified) — a smaller gain, but the minified file also parses slightly faster and takes less space in the app bundle. Sorting keys makes the file’s changes easier to review in version control.

Privacy and large files

Your JSON is processed entirely in your browser; nothing is uploaded. Files of several megabytes minify in well under a second on modern devices. For very large datasets or automated pipelines, use a command-line tool such as jq or your language’s JSON library.

Minifying JSON embedded in web pages

Structured data (JSON-LD) in a page’s head, initial application state and configuration objects are often embedded as JSON inside script tags. Minifying them reduces HTML size slightly, but more importantly the output must be safe inside HTML: the sequence </script> inside a string would end the script block early. Frameworks usually escape this automatically; if you embed JSON by hand, escape < as \u003c. The “Escape non-ASCII” option does not do this, so check strings that contain HTML.

Minification in build pipelines

In most projects you do not minify JSON by hand. Build tools can minify JSON assets as part of bundling, API frameworks usually emit compact JSON by default in production, and static site generators can compress data files at build time. Keeping source files readable and minifying automatically gives you the best of both: clean diffs and code reviews, and small files in production. This page is useful for quick one-off jobs, checking what a minified payload looks like, and pretty-printing minified responses you are debugging.

When not to minify

Keep human-edited files — configuration in a repository, documentation examples, fixtures used in tests — pretty-printed, because readability and clean diffs matter more than size. Minify at build or deploy time instead. Also avoid minifying JSON that is signed or hashed as text, since any change to the bytes invalidates the signature even when the data is the same.

Frequently asked questions

Does minifying JSON change the data?

No. It removes only whitespace outside strings; the parsed data is identical.

How much smaller is minified JSON?

Often 20–40% for indented JSON, depending on structure.

Is minified JSON faster?

Slightly faster to transfer and parse, but HTTP compression gives the biggest transfer savings.

Can I un-minify JSON?

Yes, click Pretty-print to format it with indentation.

Why does my JSON fail to validate?

Common causes are trailing commas, single quotes, comments or missing brackets.

Is my JSON uploaded?

No, processing happens in your browser.

Does key sorting change the meaning?

No. JSON objects are unordered, so sorted keys represent the same data; arrays keep their order.