JSON Minifier
Turn strict JSON into a compact JSON.parse and JSON.stringify result while explicitly rejecting duplicate keys and unsafe numeric rewrites.
Privacy: your files never leave your device. All processing happens locally in your browser.
How to use
- 1.Paste a strict JSON value and review the displayed input character count.
- 2.Minify it; fix any strict-syntax, duplicate-key, unsafe-number, nesting, or budget error shown.
- 3.Confirm the compact output and reduction summary, then copy the complete minified JSON.
About JSON Minifier
JSON Minifier converts valid strict JSON into the compact text produced by JSON.parse followed by JSON.stringify. Paste an object, array, string, number, boolean, or null value, select Minify JSON, inspect the character reduction, and copy the result. Parsing, validation, serialization, display, and copying happen in the current browser tab. Input is not uploaded to Lizely or sent to an API. This makes the tool useful for compact API fixtures, configuration snippets, request bodies, embedded examples, logs, test cases, and transport payloads where ordinary formatting whitespace is unnecessary.
The tool is intentionally a JSON parser and serializer, not a regular-expression whitespace remover. Spaces and line breaks outside strings are insignificant in JSON and can be removed. Spaces, tabs represented by escapes, punctuation, and line-break escapes inside a string are data and must remain part of the decoded value. Parsing first ensures that braces, brackets, commas, colons, quotes, escapes, literals, and numbers follow the grammar. JSON.stringify then emits one compact representation without indentation. Object member insertion order follows JavaScript parsing and serialization behavior. Array order is preserved.
Only strict JSON is accepted. JavaScript object literals and JSON5 are different formats. Single-quoted strings, unquoted property names, comments, trailing commas, hexadecimal numbers, leading plus signs, Infinity, NaN, undefined, functions, and sparse array syntax are rejected. The tool does not silently remove comments, quote keys, repair commas, or translate JavaScript syntax into JSON. A valid top-level value does not have to be an object or array; strings, numbers, booleans, and null are valid JSON texts under RFC 8259.
Duplicate object names need special treatment because ordinary JSON.parse keeps the last value and discards earlier values. RFC 8259 warns that behavior with non-unique names is unpredictable across implementations. Before parsing, this tool walks the JSON structure, decodes every object key, and rejects a duplicate within the same object. The comparison happens after escape decoding, so a key written as a and the equivalent key written with a Unicode escape are duplicates. The same key name may still appear in different nested objects because those are separate member scopes. Rejection is explicit and prevents minification from hiding a last-key-wins data change.
JavaScript numbers also require a disclosed boundary. JSON itself permits number literals with arbitrary digit counts, while JavaScript uses binary double-precision Number values. A plain large integer can be rounded during JSON.parse and then serialized as a different value. This tool rejects every parsed integer outside Number.isSafeInteger, including integer-valued decimal or exponent forms. The exact safe boundaries are accepted. A non-finite overflow such as 1e400 is rejected because JSON.stringify would otherwise produce an incorrect null in some workflows. A nonzero numeric token that underflows to JavaScript zero is also rejected. These checks prevent the most destructive silent numeric changes.
Finite fractional values inside the supported range still use normal ECMAScript Number semantics. JSON.stringify may choose a canonical decimal or exponent spelling, as in converting -12.5e+2 to -1250. That is a representation change for the same JavaScript numeric value, not lexical preservation. If exact arbitrary-precision decimal spelling or very large identifiers matter, encode that value as a JSON string or use a purpose-built arbitrary-precision system. This tool does not preserve number tokens byte for byte and does not claim lossless handling beyond its stated safety policy.
Input is limited to exactly 1,000,000 UTF-16 code units and output has an independent 1,000,000-code-unit budget. Exact boundaries are accepted and the next character is rejected. Nothing is silently sliced, sampled, partially parsed, or partially returned. The output will normally be no longer than the input because formatting whitespace is removed, but the independent output check keeps the contract explicit. Nesting is limited to 256 levels before JSON.parse to avoid uncontrolled recursive preflight work on hostile or accidental deeply nested input.
The preflight scanner recognizes only JSON whitespace: space, horizontal tab, line feed, and carriage return. It tracks strings and escapes so braces or commas inside strings do not alter structure. Each object receives its own decoded-key set. Number tokens are checked for finite range, safe integer behavior, and underflow before native parsing. Native JSON.parse remains the final syntax authority, and native JSON.stringify produces the displayed compact text. This layering avoids inventing a replacement JSON implementation while adding protections that the native duplicate-key behavior cannot provide after parsing.
Editing the input immediately removes the old result, error, reduction summary, and copy status. A failed parse never leaves an earlier successful output visible. Clipboard writing is asynchronous and generation guarded; if the input changes while copying, a late promise cannot publish an obsolete Copied message. Clipboard denial leaves the output visible for manual selection. Cleanup cancels the status timer on unmount.
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 semantic fitness for an API. Review credentials and personal data before copying output to another system. For readable indentation use JSON Formatter. For syntax-only diagnosis use JSON Validator. For table conversion use JSON to CSV, and for the reverse table workflow use CSV to JSON.
Methodology & sources
Reject empty input or more than 1,000,000 UTF-16 code units. A bounded recursive scanner tracks strict JSON strings, arrays, objects, literals, and number tokens for at most 256 nesting levels. It decodes object names and rejects duplicates per object, including escape-equivalent names. It rejects non-finite numbers, nonzero underflow to zero, every integer-valued Number outside Number.isSafeInteger, and decimal tokens whose exact base-10 value differs from the shortest JSON.stringify spelling of the parsed Number. Numerically equivalent spellings remain accepted. Native JSON.parse provides final strict syntax validation, and JSON.stringify emits the compact representation without indentation. Output above 1,000,000 code units is rejected without truncation. Editing clears old output and errors; a clipboard generation and mounted guard prevent stale copy status.
Frequently asked questions
- Does JSON Minifier accept JSON5 or JavaScript object literals?
- No. Comments, trailing commas, single quotes, unquoted keys, NaN, Infinity, undefined, and other non-JSON syntax are rejected rather than repaired.
- What happens when an object contains the same key twice?
- The tool rejects it explicitly, including escape-equivalent names. Native JSON.parse would keep only the last value, which could hide a data change during minification.
- How are precision-sensitive JSON numbers handled?
- The tool rejects unsafe integers, non-finite overflow, nonzero underflow, and decimal tokens whose exact base-10 value would change after JavaScript Number parsing. Equivalent spellings such as 1.2300 to 1.23 remain allowed; use a quoted string for arbitrary precision.
- Is my JSON uploaded or stored?
- No. Preflight, JSON.parse, JSON.stringify, output display, and copying all run in the current browser tab.
Related tools
- JSON FormatterFormat, minify, and validate JSON in your browser — pretty-print or compress with pinpoint error locations.
- JSON ValidatorCheck if JSON is valid, pinpoint syntax errors by line and column, and see a structure diagnostic, in-browser.
- JSON To CSVConvert a JSON object array into RFC 4180-style CSV locally with default spreadsheet formula protection.
- CSV To JSONParse a bounded RFC 4180-style comma file locally and export string-preserving JSON without losing quoted commas, quotes, or line endings.
- ASCII TableLook up every standard 7-bit ASCII code with exact decimal, hexadecimal, octal, and binary values.
- BOM RemoverRemove exactly one leading U+FEFF from pasted decoded text locally while preserving every internal, trailing, or second leading occurrence.