Key Features
- Dual mode: human-friendly <strong>Format</strong> or compact <strong>Minify</strong> with one click
- Strict JSON parsing (RFC 8259 / ECMA-404) — invalid JSON is rejected early with clear errors
- Pretty-print mode normalizes indentation and line breaks for easier reading and review
- Minify mode strips insignificant whitespace and newlines while preserving data values
- Configurable indent size (1–8 spaces) and indent style (spaces or tabs) in Format mode
- ⏎ Option to always insert a final newline at end of file for clean diffs (`insertFinalNewline`)
- UTF-8 safe: preserves Unicode code points and escape sequences inside strings
- 100% client-side — your JSON is processed directly in the browser
🛠️ How to Format or Minify JSON for json-minifier
1. Paste or upload your JSON
📥 Paste JSON into the editor or drop a <code>.json</code> file into the dropzone. The tool validates input using a strict JSON parser — comments and trailing commas are not allowed.
2. Choose Format or Minify
🎛️ Use the action selector or the <strong>Format</strong>/<strong>Minify</strong> buttons to pick your mode. Format pretty-prints with indentation; Minify produces a compact one-line (or few-line) representation.
3. Adjust indentation settings (Format mode)
📏 In Format mode, choose indent size (1–8) and whether to use spaces or tabs. You can also decide whether to insert a final newline at the end of the file. Minify mode always uses the most compact whitespace.
4. Copy or download the result
📤 Review the formatted or minified JSON and then copy it or save it to a file. Use it in your API responses, configuration files, documentation or test fixtures.
Technical Specifications
Core Transformations (Strict & Safe)
Operations applied to produce a valid, standards-compliant JSON output.
| Operation | Applied | Notes |
|---|---|---|
| Strict JSON parse | ✅ | Rejects control characters, comments, trailing commas, NaN/Infinity/undefined and other non-standard tokens. |
| Whitespace removal in Minify mode | ✅ | Spaces, tabs and newlines between tokens are removed; string contents are preserved exactly. |
| Pretty-print in Format mode | ✅ | Re-emits JSON with configurable indentation and clean line breaks. |
| Key order preservation | ✅ | Object key order follows the parse/emit behavior (functionally preserved for most use cases). |
| Numeric lexemes | ✅ | Numbers are serialized according to the underlying JSON engine; no arbitrary rounding is added on top. |
| Unicode handling | ✅ | Both raw UTF-8 characters and <code>\uXXXX</code> escapes are honored by the JSON parser/stringifier. |
Compatibility & Safety Notes
How the tool behaves with edge cases and non-standard patterns.
| Case | Behavior | Recommendation |
|---|---|---|
| Comments (<code>//</code>, <code>/* ... */</code>) or trailing commas | ❌ Rejected as invalid JSON | Use a separate JSONC preprocessor or remove comments before using this tool. |
| Big integers (> 2^53−1) | ⚠️ Parse as JSON numbers | If you need exact 64-bit IDs, represent them as strings end-to-end. |
| Dates and custom types | ✅ Preserved as strings | JSON has no native date or custom type; consumers must interpret them. |
| NDJSON (line-delimited JSON) | ⚠️ Not special-cased | Minify each line separately with CLI tools when using NDJSON. |
Typical Size Reduction in Minify Mode
Actual savings depend on your original formatting and comment density.
| Input Style | Typical Savings | |
|---|---|---|
| Heavily formatted (many spaces/newlines) | 20%–40% | Common for pretty-printed config files and API responses. |
| Moderately formatted | 10%–25% | Well-indented but compact JSON. |
| Already compact | 5%–10% | Some tools already emit minimal whitespace. |
CLI Alternatives for JSON Formatting & Minification
For large files, automation and CI/CD, combine this online tool with command line utilities that mirror the same behavior.
Linux / macOS / Windows
jq — minify JSON
jq -c . input.json > output.min.jsonParses and writes compact JSON on a single line per document.
jq — pretty-print with 2-space indentation
jq . input.json > pretty.jsonReformats JSON with consistent indentation for easier reading.
Python
Minify with Python stdlib
python -c "import sys,json; print(json.dumps(json.load(sys.stdin), separators=(',',':')))" < input.json > output.min.jsonStrict parser; strips whitespace and newlines between tokens.
Pretty-print with 2-space indent
python -c "import sys,json; print(json.dumps(json.load(sys.stdin), indent=2))" < input.json > pretty.jsonFormats JSON with indentation similar to the online tool.
Node.js
Node one-liner — minify
node -e "const fs=require('fs');const s=fs.readFileSync(0,'utf8');process.stdout.write(JSON.stringify(JSON.parse(s)));" < input.json > output.min.jsonUses JSON.parse + JSON.stringify to produce compact output.
Node one-liner — pretty-print
node -e "const fs=require('fs');const s=fs.readFileSync(0,'utf8');process.stdout.write(JSON.stringify(JSON.parse(s), null, 2));" < input.json > pretty.jsonFormats JSON with 2-space indentation.
Common Use Cases
Web & API Performance
- Minify JSON API responses before serving via CDN.
- Shrink configuration payloads embedded in HTML or JS.
- Reduce localStorage/sessionStorage footprint by using compact JSON.
CI/CD & Data Pipelines
- Normalize JSON artifacts before caching or diffing.
- Apply consistent formatting to OpenAPI specs, manifests and configs.
- Minify large JSON datasets before upload to object storage.
Debugging, Logs & Telemetry
- Pretty-print deeply nested JSON logs to investigate incidents.
- Compact log payloads sent over the wire to save bandwidth.
- Prepare readable snapshots of API responses for bug reports.
❓ Frequently Asked Questions
Will formatting or minifying JSON change my data?
JSON data. Format mode only changes whitespace and indentation to make the structure easier to read. Minify mode strips insignificant whitespace between tokens while keeping keys, values, arrays and objects semantically identical.Do you support comments or trailing commas?
JSON (RFC 8259) and rejects comments and trailing commas. If you work with JSONC, use a separate preprocessor to strip comments, then format or minify the resulting strict JSON here.Will keys be reordered?
JSON engine emits objects. If your consumers rely on key order, document it and add tests, but remember that JSON itself does not define ordering semantics.How do I avoid losing big integers?
JSON numbers are represented as IEEE-754 doubles. For large IDs or sensitive numeric values (e.g., 64-bit integers), encode them as strings end-to-end so you never lose precision across systems.Is processing really client-side?
Pro Tips
Keep an unminified, well-formatted JSON version in your repository for diffs and code review; serve minified JSON in production for better performance.
Document any assumptions about key order or special numeric handling and enforce them with tests and linters.
Combine JSON minification with HTTP compression (GZIP/Brotli) to get the best possible transfer savings.
For recurring tasks (e.g., cleaning OpenAPI specs), script the CLI equivalents (jq/Python/Node) and use this online tool for quick one-off checks.
Additional Resources
Other Tools
- CSS Beautifier
- HTML Beautifier
- Javascript Beautifier
- PHP Beautifier
- Color Picker
- Sprite Extractor
- Base64 Decoder
- Base64 Encoder
- Csharp Formatter
- Csv Formatter
- Dockerfile Formatter
- Elm Formatter
- ENV Formatter
- Go Formatter
- Graphql Formatter
- Hcl Formatter
- INI Formatter
- JSON Formatter
- Latex Formatter
- Markdown Formatter
- Objectivec Formatter
- Php Formatter
- Proto Formatter
- Python Formatter
- Ruby Formatter
- Rust Formatter
- Scala Formatter
- Shell Script Formatter
- SQL Formatter
- SVG Formatter
- Swift Formatter
- TOML Formatter
- Typescript Formatter
- XML Formatter
- YAML Formatter
- Yarn Formatter
- CSS Minifier
- Html Minifier
- Javascript Minifier
- XML Minifier
- Http Headers Viewer
- PDF To Text
- Regex Tester
- Serp Rank Checker
- Whois Lookup