Home / Tools / JSON Formatter
Local · Private

JSON Formatter & Validator

Beautify, minify, validate, sort keys and escape/unescape JSON, parsed on your device, with exact error positions and a foldable tree view.

Load .json — drop or click

Files never leave your browser. Nothing is uploaded.

Result Waiting for input…

        

About JSON Formatter

JSON Formatter is a free text and code tool that runs entirely in your web browser. Paste JSON or drop a .json file: the parser checks it against strict-JSON rules, pretty-prints with your choice of 2-space, 4-space or tab indent, sorts keys alphabetically (case-insensitive), and renders parse errors with the exact line and column plus a caret under the broken character. One click minifies, escapes a document for embedding inside another JSON string, or unescapes a quoted string back to raw text, and a foldable tree view shows per-node key and item counts. Because everything happens locally on your device, your data is never uploaded, there is no sign-up, and it keeps working offline.

Five common mistakes strict JSON catches

Trailing commas. JavaScript object literals allow them; RFC 8259 strict JSON does not. {"a": 1,} parses in dev, fails when posted to a strict API. The error message names the position; remove the comma and re-validate.

Single quotes. Common in JavaScript, illegal in JSON. {'name': 'value'} is invalid; {"name": "value"} is the only legal form. The parser will point at the first single quote it finds.

Unquoted keys. Same dialect issue. {name: "value"} is JavaScript syntax, not JSON. Wrap every key in double quotes.

Embedded comments. JSON does not support comments. // comment or /* comment */ inside JSON will fail. The non-strict variant JSONC (used by tsconfig.json) does allow them, but stripping comments is a separate step before strict-JSON parsing.

Unescaped control characters in strings. Tabs, line breaks and form feeds inside string values must be escaped (\t, \n, \f). Pasting a multi-line string directly into a JSON value breaks parsing. The Escape button on the toolbar handles this for you.

Four jobs this tool covers

Job 1: API debugging. An API returns a 400 with "invalid JSON in request body." Paste the body here. The parse-error line and column points at the broken character. Most often it is a trailing comma after a templated field, or an unescaped quote inside a string value. Fix and re-send. Faster than reading the server's stack trace.

Job 2: Diff-friendly normalization. Two API responses look different but contain the same data. Sort-keys both and minify both, and the diff collapses to genuine differences instead of cosmetic key-order noise. Useful in test snapshot updates and contract-test failure triage.

Job 3: Embedding JSON inside JSON. When one API field needs to contain a JSON document as a string (a common pattern for webhook payloads or log entries), the inner document must be escape-stringified. Paste the inner JSON, hit Escape, and the result is the safely-quoted string you can drop into the outer field's string value. Unescape goes the other way for log analysis.

Job 4: Pretty-printing for humans. Logs, API responses, config files: most JSON in the wild is minified or hand-formatted inconsistently. Two-space indent is the JavaScript-ecosystem default; four-space is the Python convention. Tab is what gofmt uses for Go-derived configs. Pick the indent that matches the rest of your codebase. Pair with our JSON Validator when you need NDJSON line-by-line checks, common-mistake detection and structure stats.

Frequently asked questions

Is the JSON I paste sent anywhere?

No. The page uses the browser's native JSON.parse and JSON.stringify, and both run entirely on your device. The page is static HTML; the only network request is the initial page load. Safe for JSON containing API keys, customer records, internal config, or anything else you would not want to hand to a third party. Many free JSON tools online send data to their server for processing; this one never does.

What does 'sort keys' do?

Recursively re-orders every object's keys alphabetically (case-insensitive). Useful for diffing two API responses where the server returned the same data in different key order: sort both and the diff collapses to genuine differences. Also useful for normalizing JSON before hashing for cache keys or storing as a fingerprint. Arrays are not re-ordered (order is meaningful for arrays); only object keys move.

What's the difference between escape and unescape?

Escape converts JSON-special characters (quotes, backslashes, newlines, tabs) into their backslash-escaped form, so the result is safe to paste inside a JSON string value. Useful when you have a JSON document and need to embed it as a string field of another JSON document. Unescape does the reverse: it turns a JSON-quoted string back into the original raw text. Both operate on the textarea content as a whole, not the parsed object.

How do you find parse errors?

When JSON.parse throws, the browser's message includes a character position (Chrome, Edge), a line and column (Firefox), or only a quoted fragment of the broken source (newer Chrome builds). We normalize all three forms, compute the line and column, and render a numbered snippet of the surrounding lines with a caret under the exact column. Common errors surfaced: trailing comma after the last element of an array or object, single quotes instead of double, unquoted keys, embedded comments, control characters in strings.

Why no JSON5 / JSONC support?

JSON5 (the relaxed dialect that allows comments, trailing commas and unquoted keys) and JSONC (Microsoft's variant for tsconfig.json and similar files) follow different parse rules. This tool focuses on strict JSON per RFC 8259 because that is what every API uses. If you paste JSON5, the error message will point at the JSON5-specific construct, usually a comment or a trailing comma, that needs removing for strict-JSON validity.

What's the maximum size?

Pasted input is limited only by your browser's memory and the speed of JSON.parse on your machine; the drop-to-load button caps files at 15 MB. Modern browsers comfortably handle 10-50 MB JSON documents in a few hundred milliseconds. Above that, the textarea itself becomes sluggish to type into. For very large files (100 MB and up), use jq or a streaming JSON parser at the command line; a web textarea is not the right tool at that scale.