JSON Minifier

Compact JSON onto a single line, and see how much smaller that made it.

Runs on your deviceDeveloperWorkingNo account needed

What this tool does

JSON Minifier parses the document and writes it back out with no whitespace between tokens. Because it re-serialises a parsed value rather than deleting spaces with a regular expression, whitespace inside string values survives untouched — a description field containing line breaks keeps them — and input that is not valid JSON is refused with the line and column where parsing stopped instead of being turned into a broken one-liner.

Three optional passes run before the output is written. Drop properties whose value is null removes null-valued keys from objects, and deliberately leaves nulls that sit inside arrays alone, because deleting one would shift every index after it. Sort object keys reorders keys at every level, including objects nested inside arrays. Escape non-ASCII characters as \uXXXX rewrites accented letters, emoji and CJK text as escape sequences so the result survives a transport that is not UTF-8 clean — but it never shrinks anything: every escaped character costs six ASCII bytes, so an emoji or a run of kanji can grow the document by half again or more, and the summary then reports that growth as a negative saving.

Two things about compact JSON are worth knowing before you rely on it. An integer past the range a 64-bit float holds exactly — roughly sixteen digits, or anything above nine quadrillion — is rounded by the parser and the minified output carries the rounded number; the summary line names how many were affected and what the first one became, but it cannot recover the digits. Duplicate keys are also resolved silently — the last occurrence wins, as the JSON specification requires — so if you need those reported, run the document through JSON Validator first.

Minifying is not compression, and it is not a substitute for it. Whitespace is a small share of most payloads, and gzip or brotli on the connection already removes nearly all of it, so a server that compresses responses gains little from this step. Where it does earn its place is anywhere the bytes are counted before compression, or where the JSON has to be one line. Once the page itself has loaded, the minifying needs no network at all.

The parser here is strict, with no tolerant mode of the kind JSON Formatter offers: a .jsonc file or a tsconfig with comments has to be formatted there first, then minified here.

How to use it

  1. Paste the JSON. One complete document per run — a single object, array or value. Newline-delimited JSON is rejected as text after the end of the document; use JSONL Validator for that format.
  2. Choose the optional passes. Dropping null properties, sorting keys and escaping non-ASCII are all off by default, so leaving them alone gives a plain whitespace strip and nothing else.
  3. Read the saving, then copy the output. Sizes are measured in UTF-8 bytes on your own document. Anything under a kilobyte is reported as an exact byte count; above that the figures are rounded to KB or MB, while the percentage is worked out from the exact bytes either way.

Processing & privacy

Runs on your device. Your file is processed directly in this browser.

Common use cases

Putting JSON somewhere that allows one line

A data attribute, an environment variable, a log field or a single CSV cell cannot hold indented JSON. Compact JSON fits on the line these expect.

Fitting inside a size limit

QR codes, URL fragments and per-key storage quotas cap the payload before any compression happens, so removing the indentation is a real gain there.

Comparing or checksumming two documents

Minify both with Sort object keys enabled and formatting and key order stop mattering, so identical data produces an identical string to hash or diff.

Trimming a fixture before it is embedded

Test data pasted into source, a seed file or a config blob adds indentation nobody reads once it is inside another file.

Questions

Is the JSON I paste sent anywhere?
No. The parse and the re-serialise both run in this browser tab, so the document itself is never transmitted to OmniKitly and never written to storage. The page's own anonymous view count is the only request it makes, and it carries nothing from your input.
How much smaller will my file get?
Entirely dependent on how much whitespace it carried: a four-space-indented config loses far more than a payload that was already close to compact. The tool measures your actual document rather than quoting a typical figure.
Does minifying change my data?
Keys, values and types are preserved, and key order stays as you wrote it unless you switch sorting on. The two exceptions are integers too large for a 64-bit float, which are rounded, and duplicate keys, which collapse to the last one.
Why is JSON rejected here when JavaScript accepts it?
This tool parses strict JSON. Comments, trailing commas, single-quoted strings and unquoted keys are all invalid even though several are fine in a JavaScript source file, and the error names the line and column where parsing stopped.
Should I minify instead of enabling gzip?
No — enable compression first. Gzip and brotli remove repeated whitespace far more effectively than this does, and minifying a response that is already compressed on the wire buys very little.
Can I undo it and get the indented version back?
Mostly. Whitespace carries no information, so pasting the compact output into JSON Formatter restores the indentation you prefer. What does not come back is anything the optional passes removed: properties dropped by the null pass are gone, and an integer the parser rounded stays rounded.

Related tools