JSON Formatter · Prettify · Minify · Validate
Online JSON formatter / minifier / validator with custom indent, lag-free large inputs, and structured error messages. Runs entirely in your browser — JSON never uploaded, safe for sensitive data.
Overview
JSON formatting / minifying / validating is one of the most-used daily dev tools — from API debugging to log triage to config file cleanup. This tool offers Format, Minify, and Validate modes using the browser's native JSON parser, with customizable indent (0-8 spaces). Large inputs (>5MB) use useDeferredValue to avoid typing lag. Everything runs locally in your browser — JSON never leaves your machine, so you can safely paste tokens or internal API responses for debugging.
How to use
- Pick mode at top: Format (pretty multiline), Minify (single line), Validate (check only)
- Paste JSON into the input box
- Result shows instantly (invalid JSON renders a red error row with precise location)
- In Format mode, adjust indent spaces (default 2)
Formula
Under the hood: browser's native JSON.parse(input) → JS object → JSON.stringify(obj, null, indent). Format: JSON.stringify(parsed, null, indent) [0..8 clamped] Minify: JSON.stringify(parsed) [no whitespace] Validate: JSON.parse only; ok=true if no throw Error handling: try/catch around parse, never throws/alerts; error msg includes char offset.
Common scenarios
Scenario 1 · Debug a compressed API response
Backend returns single-line minified JSON that's unreadable. Paste → Format → instantly see the structure. Invalid JSON shows a precise error with char offset.
Scenario 2 · Embed JSON in an HTML attribute
data-props='{"a":1}' type attrs need minified JSON. One click on Minify mode, done.
Scenario 3 · Validate a 3rd-party webhook payload
Suspicious webhook body? Paste → Validate → only checks legality without modifying. Trailing commas / unquoted keys surface immediately.
FAQ
Is my JSON uploaded to your server?
No. All parsing, formatting, and validation run locally in your browser. JSON never leaves your device — safe to paste tokens or internal API responses.
What's the size limit for JSON input?
No hard cap — depends on browser memory (typically 512MB-2GB in modern browsers). Inputs >5MB may feel slow; we use useDeferredValue to mitigate typing lag.
Why isn't the error message more precise when parsing fails?
The error comes straight from the browser's native JSON.parse, which includes char offset but not always line number. Firefox / Chrome / Safari differ slightly; we surface the raw msg to avoid wrapping misdirection.
Can it auto-read from clipboard?
No auto-clipboard read (requires user permission, inconsistent browser support). Manual Cmd/Ctrl + V paste is straightforward and avoids permission prompts.
Does it support JSON5 / JSONC (JSON with comments)?
Not supported. This tool uses native JSON.parse per RFC 8259 — no trailing commas, unquoted keys, or // comments. JSON5 / JSONC need separate parsers, which this tool avoids.
Is formatted content cached locally? Does it persist next visit?
No. The tool does not read/write localStorage or IndexedDB; refreshing the page clears everything. Copy the result to your own file to save.
Related tools
Color Converter · HEX RGB HSL Three-way Conversion
Online color format converter for HEX / RGB / HSL. Type any format, the other two sync instantly with live swatch preview. Runs entirely in your browser — nothing uploaded.
LLM API Inference Cost Calculator – GPT, Claude, Gemini, DeepSeek
Estimate API costs for GPT, Claude, Gemini, DeepSeek and Qwen LLMs with input/output token pricing, prompt caching discounts and USD-CNY conversion. Forecast daily, monthly and yearly bills to plan your AI product budget with confidence.
2026 May Day Overtime Pay Calculator – Daily Rate Checker
Locked to China's 2026 May Day holiday (May 1–5). Check each day you worked overtime to instantly see per-day and total pay at the correct multiplier: 3× for statutory holidays (May 1–2) and 2× for compensatory rest days (May 3–5). Salary folded locally in your browser — no data uploaded.
Provident Fund Withdrawal Calculator: 7 Cities, 6 Scenarios
Check housing provident fund withdrawal limits for Beijing, Shanghai, Guangzhou, Shenzhen and 3 more cities. Covers 6 withdrawal scenarios — home purchase, loan repayment, rental, resignation, serious illness and retirement — with required materials and frequency rules.