JSON Minifier
Compress JSON for production — strip whitespace, comments, and trailing commas.
How to use JSON Minifier
- Paste your JSON or JSONC document into the input pane on the left.
- Pick Strict JSON or JSONC at the top — JSONC accepts comments and trailing commas, strict does not.
- Toggle Sort keys, Strip nulls, or Strip empty objects/arrays if you want structural cleanup in addition to whitespace removal.
- Watch the minified output update live. The byte-size, character-count, and line-count chips at the bottom show the before/after savings.
- Press ⌘/Ctrl + Enter to copy the minified output and update the shareable URL, or click Copy output.
JSON Minifier
Shrink a JSON (or JSONC) document down to the smallest valid single-line representation — entirely in your browser. Paste in pretty-printed JSON, a tsconfig.json-style config with comments, or a multi-megabyte API dump; get back the byte-minimum form with a precise, UTF-8-accurate size comparison. No server, no telemetry, no silent tricks.
Why another JSON minifier
Most web-based JSON minifiers fall into one of three traps:
- They POST your input to a server. Any payload you paste ends up in someone else's access log — which is catastrophic for anything carrying secrets (JWTs, session tokens, internal IDs, customer PII).
- They reject JSONC.
tsconfig.json,.vscode/settings.json,deno.json, andjsconfig.jsonall allow comments and trailing commas. Strict-only minifiers force you to manually scrub the file first. - They misreport savings. Many UIs display
input.length - output.lengthin characters, which under-counts the real wire cost. A 100-character JSON document containing one emoji is 103 UTF-8 bytes, not 100.
The tool fixes all three. The minifier runs client-side using the same JSON.parse/JSON.stringify primitives that ship with V8. JSONC support is built in via a hand-rolled state machine that strips comments and trailing commas without ever touching string contents. Byte accounting uses TextEncoder so the reported savings match exactly what a server would see.
What it does
- Strict JSON minification. Parses your document with
JSON.parseand re-emits it withJSON.stringify— no spaces, no newlines, no unnecessary whitespace. RFC 8259-compliant by construction. - JSONC mode. Strips
//line comments,/* */block comments, and trailing commas before parsing. The stripper is a small character-by-character state machine that respects string literals and escape sequences, so"http://example.com"and"foo\/\/bar"are preserved verbatim. - Sort keys alphabetically. Applied recursively at every nesting level. Array element order is never touched. Useful for diff-friendly config files and deterministic content hashes.
- Strip null fields. Recursively drops any object property whose value is exactly
null. Array elements are positional and remain unchanged —[1, null, 3]stays as-is. - Strip empty objects and arrays. A bottom-up pass removes
{}and[]values at any nesting level. Combined withStrip nulls, this cleans configs where nulls collapse parents into emptiness. - Accurate byte savings.
new TextEncoder().encode(s).lengthcounts real UTF-8 bytes. The percent reduction is(1 - minified / original) * 100rounded to one decimal. Character counts and line counts are reported separately. - Typed error reporting. Parse failures surface as
{ message, line, column }— the error banner includes the 1-based line/column derived from the native parser message.
Keyboard shortcuts
- ⌘/Ctrl + Enter — copy the minified output to the clipboard and update the URL share link
- ⌘/Ctrl + K — open the global command palette and jump to another tool
The shortcut fires even while focus is inside the textarea because it includes a modifier.
Privacy promise
There is no JSON-handling endpoint on dev101.io. The minifier ships as a plain client-side module with zero new runtime dependencies beyond the platform primitives every browser already provides. The optional Share button encodes the current input (when under ~4 KB) plus the option flags into the URL fragment; fragments are not transmitted to servers by any standards-compliant HTTP client.
What's not supported (yet)
- JSON5. Single-quoted strings, unquoted keys, hex literals, and
Infinity/NaNare beyond the JSONC subset supported here. A dedicated JSON5 parser is on the roadmap. - Schema-based pruning. If you want to strip properties that do not match a JSON Schema, that is a separate tool — the forthcoming JSON Schema validator will handle it.
- Streaming. The minifier loads the whole document into memory. For multi-gigabyte files, use a streaming CLI such as
jq -c.
Related tools
- JSON Formatter — the inverse operation: pretty-print and validate JSON with indent control.
- JSON Diff — structural, order-insensitive diff between two JSON documents.
- JSON Escape / Unescape — round-trip raw text to and from JSON string literals.
- JSON to YAML — convert configuration between JSON and YAML losslessly.
Frequently asked questions
What is the difference between strict JSON and JSONC mode?
Strict mode follows RFC 8259 exactly — comments and trailing commas are rejected, matching what `JSON.parse`, `jq`, and every production JSON parser will accept. JSONC mode accepts `//` line comments, `/* */` block comments, and trailing commas (as in `tsconfig.json`, VS Code settings, and Deno configs). The JSON Minifier strips the comments and trailing commas with a small hand-rolled state machine, then hands the cleaned text to the native `JSON.parse` so the output is always production-safe strict JSON.
Does the minifier modify the data, or only the formatting?
By default only formatting — whitespace is removed and the output is a single line, but every key, value, and array element round-trips unchanged. The optional `Sort keys` toggle reorders object keys alphabetically at every level (arrays stay positional). `Strip null fields` drops any property whose value is exactly `null`. `Strip empty objects/arrays` drops `{}` and `[]` values bottom-up. These toggles change structure deliberately; leave them off when you need byte-for-byte equivalence.
Is my JSON uploaded anywhere?
No. The minifier runs entirely in your browser using the native `JSON.parse` and `JSON.stringify` primitives. There is no minification endpoint on dev101.io — we deliberately avoid round-trips so secrets inside payloads (API keys, JWTs, customer records) never leave your device. The Share button encodes state into the URL fragment (`#s=…`), which browsers never send to servers. If your input is over ~4 KB, only the options are persisted into the hash.
How are the byte savings calculated?
Both the original and minified sizes are measured in UTF-8 bytes using `new TextEncoder().encode(s).length`. This matters because JavaScript strings are UTF-16 code units — `"🚀".length` is 2 but the character takes 4 bytes when transmitted over HTTP. The reported percentage is `(1 - minified / original) * 100`, rounded to one decimal place. A zero or negative reduction can happen on already-minified input; the tool reports that honestly instead of fabricating a number.
Related tools
JSON Formatter
Format, validate, and minify JSON in your browser — privately.
JSON Escape / Unescape
Escape and unescape JSON strings in your browser — privately.
JSON Diff
Compare two JSON documents and see added, removed, and changed fields — privately.
JSON ↔ YAML Converter
Convert JSON to YAML and YAML to JSON in your browser — privately.