Loading...
Loading...
Paste JSON to pretty-print, validate, minify, or sort keys. Errors land on the exact line and column with a helpful hint.
A JSON formatter takes raw, minified, or pasted JSON and re-emits it with consistent indentation so humans can read it. This tool goes further — it validates the input, tells you exactly where a parse error lives (line and column), minifies for production payloads, sorts keys so diffs stay stable across rebuilds, and reports structure metrics like max depth and key count. Everything runs in your browser with the native `JSON.parse` engine, so the data never leaves your device. It handles files up to a few megabytes without breaking a sweat — ideal for API responses, config files, or debugging a nested webhook payload.
Drop raw, minified, or malformed JSON into the input pane. Parsing runs as soon as you stop typing.
Choose 2 spaces, 4 spaces, or a tab. Most style guides prefer 2 spaces; internal tooling often uses tabs.
Click Format to pretty-print or Minify to strip whitespace. Toggle 'Sort keys' to emit object keys alphabetically for stable diffs.
If the JSON is invalid you'll see the exact line and column, with a short message like 'Unexpected token' or 'Expected comma'.
Use the Copy button to put the formatted or minified result on your clipboard, ready to paste into code or Postman.
parsed = JSON.parse(input) // native validator pretty = JSON.stringify(parsed, null, indent) minified = JSON.stringify(parsed) sortedKeys = recurse(parsed, sort object keys) // applied pre-stringify error.line = count of '\n' before error.offset error.column = error.offset − last '\n' index
Parsing uses the browser's built-in `JSON.parse`, which follows RFC 8259 strictly — comments, trailing commas, and single-quoted strings are rejected. When parsing throws, the error message carries a `position` (zero-based offset) on modern engines; we convert it into a line and column pair so you can jump straight to the problem. Indent and sort-keys are applied in JavaScript memory, not via regex, so nested structures always round-trip correctly.
Reference: RFC 8259 — The JSON Data Interchange Format
| Input | Result |
|---|---|
{"name":"Ada","skills":["math","code"]} | Formatted with 2-space indent; 4 lines, 2 keys, depth 2 Typical API response being prettified for human review. |
{ name: 'Ada' } | Invalid JSON at line 1, column 3 — property names must be double-quoted Common JS-object-literal mistake caught by strict RFC 8259. |
{ "b": 2, "a": 1, "c": { "z": 9, "m": 5 } } | Sort keys ON → { "a":1, "b":2, "c": { "m":5, "z":9 } } Stable diffs — recommended for committed config files. |
Encode and decode Base64 text with optional URL-safe variant and UTF-8 support.
Split JSON Web Tokens into header, payload, and claims with readable expiry dates.
Convert between epoch numbers and dates with auto-detect for seconds vs milliseconds.
Calculate your exact age in years, months, and days from any date of birth.
Last updated