Loading…

About Online JSON Formatter & Minifier

Need to clean up messy JSON or shrink oversized API responses? This JSON Formatter & Minifier parses your data in strict RFC 8259 mode, then either pretty-prints it with clean indentation or removes insignificant whitespace for a compact, production-ready result. Everything runs in your browser — ideal for debugging, documentation, or quick performance wins.

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

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

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

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

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.

OperationAppliedNotes
Strict JSON parseRejects control characters, comments, trailing commas, NaN/Infinity/undefined and other non-standard tokens.
Whitespace removal in Minify modeSpaces, tabs and newlines between tokens are removed; string contents are preserved exactly.
Pretty-print in Format modeRe-emits JSON with configurable indentation and clean line breaks.
Key order preservationObject key order follows the parse/emit behavior (functionally preserved for most use cases).
Numeric lexemesNumbers are serialized according to the underlying JSON engine; no arbitrary rounding is added on top.
Unicode handlingBoth 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.

CaseBehaviorRecommendation
Comments (<code>//</code>, <code>/* ... */</code>) or trailing commas❌ Rejected as invalid JSONUse a separate JSONC preprocessor or remove comments before using this tool.
Big integers (> 2^53−1)⚠️ Parse as JSON numbersIf you need exact 64-bit IDs, represent them as strings end-to-end.
Dates and custom types✅ Preserved as stringsJSON has no native date or custom type; consumers must interpret them.
NDJSON (line-delimited JSON)⚠️ Not special-casedMinify 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 StyleTypical Savings
Heavily formatted (many spaces/newlines)20%–40%Common for pretty-printed config files and API responses.
Moderately formatted10%–25%Well-indented but compact JSON.
Already compact5%–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.json

Parses and writes compact JSON on a single line per document.

jq — pretty-print with 2-space indentation

jq . input.json > pretty.json

Reformats 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.json

Strict 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.json

Formats 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.json

Uses 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.json

Formats 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?

No. Both modes preserve the underlying 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?

The online tool enforces strict 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?

No key-sorting step is applied. The order generally reflects how the underlying 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?

Yes. Parsing and formatting/minifying are performed in your browser via a dedicated adapter. As a best practice, avoid pasting extremely sensitive secrets into any online tool and prefer local/CI workflows for high-risk data.

Pro Tips

Best Practice

Keep an unminified, well-formatted JSON version in your repository for diffs and code review; serve minified JSON in production for better performance.

Best Practice

Document any assumptions about key order or special numeric handling and enforce them with tests and linters.

Performance Tip

Combine JSON minification with HTTP compression (GZIP/Brotli) to get the best possible transfer savings.

Best Practice

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