Home › Developer Tools › JSON Minifier

JSON Minifier

Paste JSON to strip every unneeded space and line break. The minifier validates as it goes, points to the exact line and column of any error and never rounds your numbers.

Last updated:

Original–
Minified–
Gzipped–
Saved–

Advertisement
Advertisement

How to use the JSON Minifier

  1. Paste your JSON into the left box, or upload / drop a .json file.
  2. Pick options: sort keys, accept comments and trailing commas (JSONC) or escape non-ASCII characters.
  3. Press Minify JSON (the output also updates as you type).
  4. Fix any error: the message shows the line and column and a caret marks the exact character.
  5. Copy or download the minified JSON and check the bytes saved.

What JSON minification removes

JSON (RFC 8259) allows four whitespace characters between tokens: space, tab, line feed and carriage return. A minifier deletes all of them outside strings and changes nothing else. Whitespace inside a string value is data and is always kept.

InputMinifiedNote
{ "a" : 1 , "b" : [ 1, 2 ] }{"a":1,"b":[1,2]}Spaces around : , [ ] { } removed
{"msg": "hello world"}{"msg":"hello world"}Spaces inside strings are kept
{"id": 12345678901234567890}{"id":12345678901234567890}Numbers copied exactly, no rounding
{"x": 1.50, "y": 1e3}{"x":1.50,"y":1e3}Number spelling is preserved
{"b": 1, "a": 2} + Sort keys{"a":2,"b":1}Keys ordered, arrays untouched
{"a": 1, // note
"b": [2,],} + JSONC
{"a":1,"b":[2]}Comments and trailing commas stripped

Common JSON errors and how to fix them

Error messageTypical causeFix
Unexpected “]”: trailing commas are not allowed[1, 2,]Delete the last comma, or enable JSONC
Expected a property name in double quotes{name: "x"} or {'name': "x"}Quote keys with "
Expected “,” or “}” after a property valueMissing comma between two propertiesAdd a comma at the caret
Unescaped control character in stringA real line break or tab inside a stringWrite \n or \t instead
Numbers cannot have leading zeros{"zip": 01234}Use a string: "01234"
“True” / “None” / “NaN” is not valid JSONPython or JavaScript literals pasted as JSONUse true, false, null or a number

How the size saving is calculated

Sizes are counted in UTF-8 bytes, the encoding used on the web. Saved % = (original bytes − minified bytes) ÷ original bytes × 100. For example, the 276-byte sample in the tool minifies to 219 bytes, a saving of 57 bytes or 20.7%.

The gzip figure is produced with your browser's built-in CompressionStream. Servers usually compress JSON responses with gzip or Brotli, so minifying and compressing together gives the smallest transfer. Minification still helps: it reduces memory use, storage and the work the compressor has to do, and it makes cache keys and hashes stable when combined with key sorting.

Frequently asked questions

What does a JSON minifier do?

It removes all whitespace that sits outside strings: spaces, tabs and line breaks used for indentation. The data stays exactly the same, so any JSON parser reads the minified file identically, but it is smaller to store and send.

Will minifying change my numbers or strings?

No. This tool uses its own parser that copies every number and string exactly as you wrote it, so large integers such as 12345678901234567890 and escapes such as \u00e9 are kept. Many online tools use JSON.parse, which rounds numbers above 2^53.

How do I find a JSON syntax error?

The minifier validates while you type. If the JSON is invalid it shows the line and column, explains what was expected and draws a caret under the offending character. Common causes are trailing commas, single quotes and missing commas between items.

What does Sort keys do?

It orders the keys of every object alphabetically, recursively, comparing UTF-16 code units like the JSON Canonicalization Scheme. Sorted, minified JSON is handy for diffs, hashing and caching. Array order is never changed.

Can it handle comments and trailing commas?

Yes. Tick “Allow comments & trailing commas (JSONC)” and the tool accepts // and /* */ comments plus trailing commas, as used in tsconfig.json or VS Code settings, and outputs strict JSON.

How much smaller does JSON get?

Pretty-printed JSON with two-space indentation usually shrinks by 15–40%. The gzip figure shows what the file would weigh when served with compression, which is what matters over the network.

Is my JSON uploaded anywhere?

No. Parsing, minifying and the gzip estimate all run inside your browser. Nothing you paste or upload leaves your device.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

JSON FormatterBeautify, minify and validate JSON, with a collapsible tree view.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.JavaScript MinifierMinify JavaScript with Terser: compress, mangle and see how many bytes you save.CSS MinifierMinify CSS with csso or a built-in engine and see the size saved instantly.JSON to TOML ConverterConvert JSON to clean TOML with tables, arrays of tables, inline tables and dates.SQL Formatter & BeautifierFormat, beautify or minify SQL queries for MySQL, PostgreSQL and more.JavaScript BeautifierFormat and beautify messy or minified JavaScript, or minify it.HTML FormatterBeautify and indent HTML code with a live preview.CSS FormatterBeautify CSS with indent controls and optional property sorting.XML FormatterBeautify, validate and minify XML with a collapsible tree view.ZIP File CreatorCompress files and folders into a ZIP.YAML Validator & FormatterValidate, format and minify YAML, and convert YAML to JSON or back.HTML MinifierMinify HTML: strip comments and whitespace safely and see how many bytes you save.Code Diff CheckerCompare two code files side by side or unified, with syntax colors and changes highlighted.IPv6 Expander & CompressorExpand IPv6 addresses to full form or compress them per RFC 5952, one or many at once.GraphQL FormatterPretty-print and indent GraphQL queries, mutations and schemas, or minify them, instantly.CSS ValidatorValidate CSS: syntax errors, unknown properties and invalid values by line, plus auto-fix.Gzip Compress / DecompressGzip or deflate text and files, get Base64 output, and decompress Base64 or .gz files.IBAN ValidatorCheck an IBAN's mod-97 checksum, country and length, and see its bank code and account parts.JavaScript Syntax CheckerCheck JavaScript for syntax errors with line and column, for any ES version, script or module.JSON Schema ValidatorValidate JSON against a JSON Schema (draft-07, 2019-09, 2020-12) with clickable error paths.Markdown FormatterBeautify Markdown with Prettier: list markers, prose wrap, aligned tables and live preview.PHP FormatterBeautify PHP code with Prettier PHP: PSR-12 style, indent and brace options, syntax errors.TypeScript FormatterFormat TypeScript and TSX code with Prettier: width, tabs, semicolons and quotes options.XML MinifierMinify and validate XML: strip whitespace and comments, keep CDATA, see the size savings.C# FormatterBeautify C# code online: Allman or K&R braces, indent size and line width, clang-format option.HTML ValidatorCheck HTML for errors and warnings with line numbers, locally or with the W3C Nu checker.Java FormatterBeautify Java code online: indent size, brace style and line width, with clang-format option.JavaScript ObfuscatorObfuscate JavaScript with string encoding, renaming and control-flow flattening presets.Phone Number FormatterFormat and validate lists of phone numbers to E.164, international or national style.Python FormatterFormat Python code in Black/Ruff style: line length, quote style, indent, copy or download.Responsive Design CheckerPreview any website at phone, tablet, laptop and desktop sizes side by side, with rotate and zoom.Browser Compatibility CheckerSearch CSS, JavaScript and HTML features and see which browser versions support them.Core Web Vitals CheckerCheck real-user LCP, INP and CLS for any URL or site and see if it passes Core Web Vitals.Heading Structure CheckerPaste HTML to see its H1-H6 outline and catch missing H1s, multiple H1s and skipped levels.Website Hosting CheckerFind out who hosts a website: hosting provider, IP addresses, ASN, network owner and location.Routing Number ValidatorCheck a US ABA routing number's checksum and format and see its Federal Reserve district.Spam Word CheckerScan an email subject and body for spam trigger words, excess caps, exclamation marks and risky links.Strftime Format BuilderBuild Python and C strftime format strings by clicking tokens, with a live preview and reference.Check Digit CalculatorCalculate or validate check digits for UPC, EAN, GTIN, SSCC, ISBN, ISSN and mod 11 codes.Luhn Algorithm CheckerValidate numbers with the Luhn mod 10 check or calculate the missing check digit, step by step.XSD ValidatorValidate XML against an XSD schema in your browser and see each error with its line number.
See all 41 Code Formatters & Validators →