Minifying JSON in VS Code produces the compact single-line text that JSON.parse followed by JSON.stringify would emit — the same whitespace-free representation an API expects in a request body, a configuration file, or a log line. VS Code includes excellent JSON tooling: IntelliSense, schema validation, code folding, and the Format Document command (Shift+Alt+F on Windows and Linux, Shift+Option+F on macOS), but it does not ship a one-click "minify" command, so the formatting action pretty-prints instead. Developers who want a compact payload usually reach for a marketplace extension, a shell pipeline such as jq -c or a node one-liner, or an external tool. The right choice depends on what you trust with the data, because many "JSON minify" pages accept JSON5 or loose JavaScript object literals and silently repair them, which can hide duplicate keys, unsafe integer rounding, or non-finite overflow behind a successful "Copied" button. A strict in-browser JSON Minifier keeps the canonical compact representation while explicitly rejecting the inputs that cause silent precision loss and ambiguous last-key-wins behavior.

Why VS Code Alone Doesn't Minify JSON
VS Code's built-in JSON language features are designed around reading and editing, not around producing transport-ready text. When you open a .json file, the editor reads the grammar, applies any matching $schema, and offers hover documentation, completion, and outline navigation. Format Document applies an indentation rule from your settings — usually two or four spaces — which is the opposite of what minification needs. Format Document with the type set to json never removes existing newlines between top-level values; it normalizes them. There is no keyboard shortcut that strips formatting whitespace from a JSON document while preserving data integrity. Marketplace extensions bridge that gap by registering their own commands, but each one runs with the editor's privileges and may request shell access, telemetry, or network calls. For a one-off snippet — a fixture, a config sample, a payload copied from a test runner — opening a browser tab and using a strict local tool avoids installing or trusting any extension at all. The browser approach also keeps the minified output inspectable in the same place where you read the result, so it is easy to confirm what changed before pasting the compact text back into your VS Code buffer.
Three Workflows for Minifying JSON in VS Code
Each common approach has a different trade-off in trust, strictness, and convenience. A quick comparison:
| Approach | Where it runs | Strict JSON only | Catches duplicate keys | Catches unsafe numbers | Data leaves your machine |
|---|---|---|---|---|---|
| Marketplace extension | Inside VS Code | Varies by extension | Varies by extension | Varies by extension | Varies by extension |
| Shell pipeline (jq -c, node, python) | Local terminal | Strict | No — keeps last value | No — keeps lossless text | No |
| Browser-based JSON Minifier | Current browser tab | Yes | Yes | Yes | No |
The shell pipeline row deserves a note: jq -c produces compact text but, like JSON.parse, keeps the last value when the same key appears twice. The browser tool row catches that because it walks the structure before parsing, decodes each key, and rejects a duplicate within the same object — including keys written with Unicode escapes that decode to the same name.
Minify JSON From VS Code With the JSON Minifier
The shortest path from a JSON buffer in VS Code to a minified string is a copy-paste round trip through the browser:
- In VS Code, open the JSON file and select the snippet you want to minify. Ctrl+A or Cmd+A selects the entire document if you want to compress the whole file.
- Copy the selection to the clipboard with Ctrl+C or Cmd+C.
- Open the JSON Minifier in a browser tab and paste the selection into the input area.
- Read the displayed input character count so you know whether the payload fits inside the 1,000,000 UTF-16 code unit input budget.
- Click Minify JSON.
- Read the result panel. If an error appears, follow the message back to VS Code, fix the strict-syntax, duplicate-key, unsafe-number, nesting, or budget issue, and try again.
- Confirm the compact output and the reduction summary that shows how many characters were removed.
- Click Copy and paste the minified JSON back into your VS Code buffer, an API client, a config file, or wherever the payload is needed.
The minifier's editing semantics help when iterating: editing the input immediately removes the old result, error, reduction summary, and copy status, so a stale "Copied" message from a previous attempt cannot be confused with the current state. Clipboard denial leaves the output visible for manual selection.
What the Strict JSON Minifier Checks
A plain JSON.parse call is enough to produce compact text through JSON.stringify, but plain parsing silently keeps the last value for duplicate keys and silently rounds any integer outside Number.isSafeInteger. The JSON Minifier layers a bounded preflight pass before the native parser runs, so the data is checked for the cases that cause the most destructive silent changes:
- It decodes every object key and rejects duplicates within the same object, including keys written as Unicode escapes that decode to the same name. The same key may still appear in different nested objects because those are separate member scopes.
- It rejects non-finite overflow such as 1e400, nonzero tokens that underflow to JavaScript zero, and every integer-valued number outside Number.isSafeInteger. The exact safe boundaries are accepted.
- It rejects decimal tokens whose exact base-10 value would change after JavaScript Number parsing, while still allowing equivalent spellings such as 1.2300 to 1.23.
- It enforces a 256-level nesting cap before JSON.parse to avoid uncontrolled recursive work on deeply nested input.
- It tracks strings and escapes during the preflight walk, so braces, brackets, and commas inside strings are not misinterpreted as structure.
Native JSON.parse remains the final authority on strict syntax, and native JSON.stringify emits the compact representation without indentation. This layering is documented in the tool's implementation methodology and avoids reinventing a JSON parser while adding protections that the native duplicate-key behavior cannot provide after parsing.
Limits, Errors, and Output Boundaries
The tool enforces every limit explicitly so minification cannot silently truncate or sample input. The exact boundaries are accepted, and the next character or level is rejected:
| Boundary | Value | Behavior at and beyond the limit |
|---|---|---|
| Input size | 1,000,000 UTF-16 code units | Exact size accepted; next character rejected |
| Output size | 1,000,000 UTF-16 code units | Independent budget; no truncation |
| Nesting depth | 256 levels | Exact depth accepted; deeper rejected |
| Duplicate keys (same object, same decoded name) | 0 duplicates | Rejected in preflight |
| Integers outside Number.isSafeInteger | Detected token-by-token | Rejected in preflight |
| Non-finite overflow (for example 1e400) | Detected in preflight | Rejected |
| Nonzero underflow to JavaScript zero | Detected in preflight | Rejected |
| JSON5 and JavaScript object literal syntax | Comments, trailing commas, single quotes, unquoted keys, NaN, Infinity, undefined | Rejected, never repaired |
Editing the input clears any previous output and error. A failed parse never leaves an earlier successful result visible, and the clipboard write is generation-guarded so a change made while copying cannot publish an obsolete "Copied" message. Input and output are processed in the current browser tab; nothing is uploaded to Lizely or sent to an API.
When You Need Pretty-Printing or Validation Instead
Minification is one step in a JSON workflow, and the compact text is rarely the final destination. The same browser-tab approach offers neighbors worth knowing about when the next step is the opposite of compression:
- For readable indentation after minification, paste the compact output into JSON Formatter to inspect structure.
- For a syntax-only diagnosis with line and column pinpointing, JSON Validator is the dedicated tool, with no numeric safety checks layered on top so it stays close to the raw grammar.
Minification does not validate an application-specific schema, sort object keys, remove fields, deduplicate arrays, redact secrets, compress with gzip, convert JSON to JavaScript, or make untrusted data safe to execute. A smaller character count does not prove the payload is semantically correct for an API. Review credentials and personal data before copying the minified result to another system, and use a JSON string or a purpose-built arbitrary-precision system when exact decimal spelling matters more than the JSON.parse / JSON.stringify representation.