---
slug: json-minifier-calculator
title: "JSON Minifier Calculator"
category: developer
updated: 2026-11-17
canonical: https://calcseed.com/c/developer/json-minifier-calculator/
html: /c/developer/json-minifier-calculator/
---

# JSON Minifier Calculator

Remove whitespace and shrink JSON to its smallest valid form, with before and after sizes. Free, instant and private.

## Quick answer

**Quick answer:** with the default inputs ({
  "name": "Ada",
  "age": 36,
  "active": true
}), the minified json is **50**. At these inputs: characters after = **37**, characters saved = **13**. Change any input to update the result.

## Default calculation

Values computed by this calculator at exactly the default inputs listed below.

### Inputs (defaults)

| Input | Value | Unit |
| --- | --- | --- |
| JSON input | {
  "name": "Ada",
  "age": 36,
  "active": true
} |  |

### Outputs at these defaults

| Output | Value | Unit |
| --- | --- | --- |
| Characters before | 50 |  |
| Characters after | 37 |  |
| Characters saved | 13 |  |

## Formula

```text
characters saved = characters before − characters after
```

## Inputs

| Variable | Type | Unit | Default |
| --- | --- | --- | --- |
| JSON input | text |  | {
  "name": "Ada",
  "age": 36,
  "active": true
} |

## Outputs

| Result | Format |
| --- | --- |
| Minified JSON | primary |
| Minified JSON | text |
| Characters before | number |
| Characters after | number |
| Characters saved | number |

## How it works

### What minification removes

JSON allows optional whitespace between tokens, and pretty-printed files spend most of their size on it: newlines, indentation and the space after each colon. Minification deletes every byte of that optional whitespace while leaving keys, values, order and structure untouched. The parser re-reads both versions identically, but the compact one is smaller to store and faster to send.

Whitespace inside quoted strings is part of the data and is never removed. A value like "Ada Lovelace" keeps its internal space, because deleting it would change the meaning of the document rather than its formatting.

### Worked example at the default input

The default document is a 4-key object pretty-printed with 2-space indentation. It measures **50 characters** before and **37 characters** after, so **13 characters** are saved — a 26% reduction. The minified output is the single line {"name":"Ada","age":36,"active":true}.

#### Where the 13 saved characters come from

The 13 saved characters decompose exactly: 4 newlines separating the 5 lines, 6 indentation spaces (2 per line across the 3 indented lines), and 3 spaces after the colons of "name", "age" and "active". 4 + 6 + 3 = 13, which matches the tool&rsquo;s saved figure character for character. Every character of the actual data — the braces, quotes, keys, numbers and booleans — survives.

| Whitespace in the default input | Count | Fate |
| --- | --- | --- |
| Newlines between lines | 4 | Removed |
| Indentation spaces (2 per indented line) | 6 | Removed |
| Spaces after colons | 3 | Removed |
| Spaces inside string values | 0 | Would be kept — they are data |

### Validation happens first

The input is fully parsed before anything is compacted. If parsing fails, the tool reports the error instead of emitting a broken result, which means a minified output from this calculator is guaranteed valid by construction. The reverse does not hold for naive whitespace-stripping scripts, which happily strip newlines inside string literals and produce a corrupted file.

Parsing also normalizes a few borderline cases: an empty object {} round-trips unchanged, duplicate keys keep the last occurrence, and large numbers are formatted per the JSON number grammar. If any of those behaviors matter for your payload, compare the output against the input before shipping it.

### How much can you expect to save

Savings scale with formatting depth. The 26% of the small default example is typical of shallow documents. A config file indented with 4 spaces per level often sheds 35–45%, because each nesting level contributes more padding than data. Deeply nested API responses with 2-space indentation usually land between 25% and 35%. Arrays of numbers with one element per line are the extreme case, sometimes exceeding 60% savings.

Note these are character counts, and for ASCII content characters equal bytes. Once the document contains multi-byte characters, byte savings differ from character savings, though minification itself is unaffected because it only removes the whitespace characters.

### When to minify, and when not to

- Minify JSON served to browsers or mobile clients, where every round trip pays for each byte
- Minify JSON embedded in HTML, config blobs or single-line log entries, where newlines break the surrounding format
- Minify before storing in systems billed by size, such as object storage or message queues
- Keep the pretty version in version control and in anything humans will read or diff

A practical pipeline keeps both: the pretty form in the repository, the minified form as a build artifact. Diffing a minified file is painful because one change rewrites the whole line, which is exactly why minified files are generated rather than edited. If you need to check that a minified payload is well-formed, the JSON Validator reports the precise error position.

### Common errors that stop minification

#### The trailing comma trap

- A trailing comma after the last item — valid-looking, but JSON grammar rejects it at that position
- Single quotes around keys or strings, where the standard requires double quotes
- Comments, which JavaScript files tolerate but JSON does not define at all
- Unquoted keys, a JavaScript object literal habit that is invalid JSON
- A stray BOM character pasted invisibly at the start of the file from a Windows editor

Each of these triggers the parse failure path, so the fix is always in the input, never in the minifier. Trailing commas are the most frequent offender in hand-edited files: {"a":1,"b":2,} parses in JavaScript but fails as JSON.

### Minification versus compression

Minification removes bytes before transfer; gzip or brotli compress what remains, and they stack. Repetitive pretty-printed JSON also compresses extremely well, so the marginal gain of minifying under gzip is smaller than the raw percentage suggests — typically a few additional percent. Minify anyway when payloads are stored uncompressed, parsed on constrained devices, or shipped through channels without transparent compression. A 50-character document saving 13 characters is trivial; a 50 MB export saving 13 MB is a meaningful download.

## FAQ

### Does minifying change my data?

No. Only optional whitespace outside strings is removed. Keys, values, number formatting and key order are preserved exactly, and a parser reading the minified output sees the identical document.

### How many characters does the default example save?

The 50-character input becomes 37 characters, saving 13 — a 26% reduction. The 13 characters are 4 newlines, 6 indentation spaces and 3 spaces after colons.

### What happens with invalid JSON?

The tool reports the parse error instead of producing output, so you fix the input first. A trailing comma, single quotes or comments are the usual causes, and each fails at an exact character position.

### Will spaces inside my string values be removed?

Never. Whitespace inside quoted strings is data, not formatting. A value like "New York" keeps its internal space; only newlines, indentation and spaces between JSON tokens disappear.

### How much smaller does JSON get when minified?

Typically 25–35% for 2-space-indented documents, 35–45% for 4-space indentation, and over 60% for one-element-per-line arrays. The small default example saves 26%.

### Should I minify before gzipping?

It still helps, but less than the raw percentage suggests, because repetitive indentation also compresses well. Expect a few additional percent on top of gzip or brotli; the bigger wins come from storing or transferring JSON uncompressed.

### Can I format the minified JSON back out?

Yes, any pretty-printer can re-expand it, and JSON.stringify(value, null, 2) in JavaScript restores 2-space indentation. No information is lost in either direction, which is why keeping only the minified artifact is safe.

### Does the order of keys change after minification?

No. The minifier serializes in the order the parser read them. JavaScript engines preserve insertion order for string keys, so the compact output keeps the original sequence.

### Why does my minified file still have spaces in it?

Those spaces are inside string values, where they are part of the data. Every remaining space sits between quote marks; all formatting whitespace between tokens has been removed.

## Method and sources

Methodology: Conversions and formats follow the relevant IETF RFCs and IEEE standards, including RFC 4648 for Base64 and RFC 791 for IPv4 addressing.

Last updated: 2026-11-17.
- RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format.
