JSON Minifier

Runs 100% in your browser

Minify and compress JSON online — remove whitespace, sort keys, escape Unicode, measure exact byte savings, and download compact JSON privately in your browser without any upload.

STEP 1 — INPUT

Readable or formatted JSON

Ready
0 bytes 0 lines
STEP 2 — OPTIONS

Compression settings

Keep order
STEP 3 — OUTPUT

Compact JSON

Waiting for valid JSON
0 bytes No output yet
AT A GLANCE

Compression statistics

Not checked
Input bytes0
Output bytes0
Bytes saved0
Reduction0%
Keys0
Nested arrays0
Max depth0
Strings0

Minification is not encryption — and it runs locally

JSON is parsed and serialized entirely in your browser using JSON.parse and JSON.stringify. Compact output removes whitespace; it does not hide secrets, replace HTTPS, or substitute for Gzip or Brotli transport compression. No data leaves your device.

SESSION ONLY

Recent minifications

Recent operations disappear when this page closes.

Frequently asked questions

A JSON minifier parses a valid JSON document and re-serializes it using JSON.stringify without indentation spaces, line breaks, or extra whitespace. It removes all non-semantic formatting while preserving every string, number, boolean, null, object, and array value. The output is data-equivalent to the original but occupies fewer bytes.

The byte reduction depends entirely on how much indentation and whitespace the original contains. A 2-space-indented JSON document with 50 keys and several nested objects typically shrinks by 15–40%. ToolsSonic reports exact input bytes, output bytes, bytes saved, and reduction percentage so you can measure the actual saving for your specific document rather than estimating.

No. A correct minifier removes only presentation whitespace — spaces, tabs, and line breaks that are outside string values. It does not alter strings, numbers, booleans, null, object keys, or array contents. The minified output parses back to the same JavaScript data structure as the original.

Yes. ToolsSonic offers three key-order modes: keep original order (default), sort A–Z for deterministic alphabetical output, and sort Z–A for reverse-alphabetical output. Key sorting changes the textual representation of objects but does not change the JSON data. Use sorted output for snapshots, diffs, canonical signatures, and fixture files where a stable key order matters.

Yes. Removing whitespace reduces the payload byte count for HTTP request bodies, API responses, webhook payloads, and embedded configuration. Keep a human-readable source copy separately — minified JSON is harder to inspect during debugging. Some APIs specify a maximum content-length for which minified payloads are practical, especially on mobile networks.

Minification removes text whitespace at the source level; the resulting text is still readable ASCII or UTF-8. Gzip and Brotli compression work at the transport layer by encoding repeated byte patterns regardless of readability. In production, the two techniques are complementary: minify first to reduce source size, then let the web server apply Gzip or Brotli for further transport-layer reduction. Minification typically saves 15–40%; HTTP compression typically saves 60–80% on top.

Yes. ToolsSonic offers two Unicode modes. Keep Unicode characters (default) preserves accented letters, emoji, Chinese characters, and other non-ASCII code points as readable UTF-8 in the output. Escape non-ASCII serializes those characters as \uXXXX escape sequences, which is useful for systems that require pure ASCII JSON, logging pipelines, or environments where multi-byte UTF-8 encoding causes issues.

Yes. Click Open JSON file and choose a local .json file from your device. ToolsSonic uses the browser FileReader API to read and minify the file entirely in your browser. No data is sent to any server, no upload endpoint exists, and no file history is stored on disk. Session history is kept only in page memory and disappears when the tab closes.

The minifier stops before producing any output, clears the output area, disables the Copy and Download buttons, and displays the browser JSON.parse error message. Fix missing quotes, trailing commas, unmatched brackets, single-quoted strings, or JavaScript-style comments, then run again. Use JSON Repair if the source is JavaScript-style JSON with comments or trailing commas before fixing.

Yes. JSON.parse and JSON.stringify handle nested objects and arrays at any depth subject to browser memory limits. For very large documents (several megabytes), the browser may take a moment to serialize. The statistics panel reports key count, nested array count, maximum nesting depth, and string count so you can assess document complexity before and after minification.

No. A single newline character after the closing bracket or brace is ignored by compliant JSON parsers. Some Unix toolchains, POSIX text-file conventions, and editors expect a trailing newline at the end of any text file. Enable the trailing newline option when your workflow or diff tool flags its absence.

No. Minification is a byte-size and presentation transformation, not an encryption or obfuscation mechanism. The compact output is as readable as the original to anyone who has access to it. Minified JSON does not hide API keys, passwords, personal data, or business logic. Continue using HTTPS, access controls, and proper secret management regardless of whether the JSON payload is minified.

Yes. The tool is designed for production workflows: it validates the JSON before minifying, reports exact byte savings so you can make an informed deployment decision, supports Unicode or ASCII-escape output, and allows downloading the minified file. For automated build pipelines, a Node.js script using JSON.parse and JSON.stringify produces identical output programmatically.

Yes on both counts. ToolsSonic's JSON Minifier is free with no registration, no rate limit, and no subscription. All processing runs locally in your browser with no upload API and no server-side serialization. You can use it for confidential API payloads, internal configuration files, and production fixtures without any data leaving your device.

A JSON Formatter reads a compact or inconsistently formatted document and writes it with readable indentation, line breaks, and optionally sorted keys. A JSON Minifier does the opposite: it reads a formatted document and writes the most compact valid representation. ToolsSonic provides both as separate focused tools that link to each other for a complete formatting workflow.

Call JSON.stringify(JSON.parse(yourString)) in any JavaScript environment. JSON.stringify with no second or third argument produces compact output with no spaces or line breaks. In Node.js, read the file with fs.readFileSync, parse, stringify, and write back. The ToolsSonic minifier performs the same operation with added key-sorting, Unicode-escape, byte-statistics, and file-download features that a one-liner cannot provide.

What is JSON Minifier?

What Is a JSON Minifier?

A JSON minifier parses a valid JSON document and re-serializes it using JSON.stringify with no indentation, no line breaks, and no extra whitespace. Every space between colons and values, every newline after a comma, and every tab used for indentation is removed. The resulting text occupies fewer bytes while remaining data-equivalent to the original — it parses back to exactly the same JavaScript objects, arrays, strings, numbers, booleans, and null values.

Minification is one of the simplest, lowest-risk optimizations available when working with JSON payloads. A 2-space-indented API response with 60 keys and moderate nesting typically shrinks 15–35%. A deeply indented configuration file can shrink 40% or more.

How ToolsSonic's JSON Minifier Works

ToolsSonic's JSON Minifier runs entirely in your browser. There is no upload endpoint, no backend serialization service, and no rate limit. Paste or load a local JSON file, choose compression options, and the tool runs JSON.parse then JSON.stringify(value) locally, reporting:

- Input bytes — exact UTF-8 byte count of the source text - Output bytes — exact UTF-8 byte count of the compact output - Bytes saved — the absolute difference - Reduction % — the percentage reduction - Key count — total object property names across all nesting levels - Array count — total nested arrays - Max depth — deepest nesting level in the document - String count — total string values

Key-Sorting for Deterministic Output

The default behavior preserves original key order, matching how the source was authored. Two additional modes are available:

Sort A–Z produces alphabetically ordered keys at every nesting level. This is useful for canonical JSON in cryptographic signatures, snapshot testing, API contract fixtures, configuration diff tools, and any workflow where a deterministic, human-reviewable key order matters. Two documents with the same data but different authored key orders will produce identical minified output when both are sorted.

Sort Z–A produces reverse-alphabetical keys, which is occasionally required by legacy systems or specific test frameworks.

Key sorting does not change JSON data meaning — JSON objects are unordered collections — but it does affect textual equality checks, byte-level signatures, and test snapshot comparisons.

Unicode: Keep or Escape

JSON strings can contain any Unicode character. ToolsSonic's minifier offers two output modes:

Keep Unicode characters (default) — accented letters like é, CJK characters, emoji, and other non-ASCII code points remain as readable UTF-8 in the compact output. This produces the smallest possible file and is correct for any modern system.

Escape non-ASCII as \uXXXX — every character above U+007E is replaced by a four-hex-digit escape sequence. This is necessary for logging pipelines that reject multi-byte characters, ASCII-only transport protocols, legacy parsers, and JSON that will be embedded inside a byte-limited context.

JSON Minification vs Gzip: Understanding the Difference

These two techniques are often confused but operate at entirely different layers:

| Technique | Layer | What It Removes | Typical Saving | |---|---|---|---| | JSON Minification | Source text | Whitespace, line breaks | 15–40% | | Gzip | Transport encoding | Repeated byte patterns | 60–80% additional | | Brotli | Transport encoding | Repeated byte patterns | 65–85% additional |

Minification and HTTP compression are complementary, not alternatives. Minify the source first, then let your web server (Nginx, Apache, Vercel, Cloudflare) apply Gzip or Brotli. The combined result is a smaller source file and a more compressible byte stream.

Common Use Cases for JSON Minification

API request bodies — REST APIs that accept Content-Type: application/json bodies benefit from a smaller payload, particularly in mobile-network environments with latency-sensitive operations.

Embedded JSON in HTML — JSON data embedded inside <script type="application/json"> tags or data-* attributes adds to page weight. Minified JSON in these contexts reduces total HTML bytes.

Production fixture files — Test fixtures and seed data files often start as human-readable JSON during development. Minifying them before committing to a build repository reduces repository size.

Configuration bundles — Feature-flag JSON, remote-config payloads, and runtime-injected configuration documents can be minified without affecting any parser that reads them.

Comparing payload sizes — Before choosing a data format (JSON vs MessagePack vs Protobuf), comparing raw and minified JSON byte sizes against other formats gives a realistic baseline.

Privacy and Security

All parsing and serialization happen in the browser. ToolsSonic's JSON Minifier contains no fetch, no XMLHttpRequest, and no WebSocket calls. Your JSON — including API keys, user data, internal business objects, and financial records — never leaves your device.

Minified JSON is not encrypted or obfuscated. Any person with access to the output can read it as easily as the original. Minification is a size optimization, not a security measure. Continue using HTTPS, authentication, authorization, and proper secret management for all sensitive data.

Common use cases

  • Reducing payload bytes in JSON API request and response bodies
  • Minifying embedded JSON inside HTML script tags and data attributes
  • Creating compact fixture files for production test suites and seed data
  • Comparing raw and minified byte sizes before choosing a data format
  • Preparing canonical sorted-key JSON for cryptographic signatures and snapshots
  • Stripping whitespace from configuration bundles before deployment
  • Measuring exact byte reduction before and after gzip compression

Why use ToolsSonic's JSON Minifier?

ToolsSonic's JSON Minifier is a privacy-first, feature-complete alternative to jsonminifier.online and codebeautify.org. It validates before minifying, reports 8 compression statistics including max depth and string count, offers 3 key-order modes, supports UTF-8 or ASCII-escape Unicode output, accepts local JSON files without uploading, runs with no rate limit, and stores nothing outside your browser session.

100% private — runs in your browser Instant — no server round-trip Free forever — no account needed