JSON Formatter
The JSON Formatter is an offline developer utility that cleans up, validates, and restructures JSON — minified single-line blobs, messy hand-written config, or raw API responses — into readable, properly indented data. Syntax errors are shown as the parser's message in a banner — no line or column is highlighted.
How to Use
- 1
Paste your JSON into the editor. Content copied from a terminal, Postman, or a browser's Network tab works as-is. (There is no file upload or drag-and-drop — paste the text.)
- 2
Choose your indent style. Pick 2 spaces, 4 spaces, or tabs to match your project's convention (check .editorconfig or your team's Prettier config if you're unsure — consistency matters more than the choice).
- 3
Read the output — or the error message. Valid JSON formats when you click Format. If it is invalid, the parser's error message is shown in a banner (no line or column is highlighted); the message tells you what the parser expected there (see the error decoder in the guide below).
- 4
Fix the flagged error and re-check. Most failures are one of five things: a missing comma, a trailing comma, single quotes, an unquoted key, or an unescaped newline inside a string. Fix it and the output appears immediately — no re-paste needed.
- 5
Minify before shipping. When the JSON is going into production — an API payload, a config file, a localStorage blob — use the JSON Minifier tool to strip every unnecessary byte; this formatter only produces indented output.
- 6
Copy or download. Use the toolbar to copy the cleaned JSON or save it as a .json file. The formatted output is safe to commit, paste into Postman, or feed to jq.
Frequently Asked Questions
What does the error message actually tell me?
Which indent should I choose — 2 spaces, 4 spaces, or tabs?
Why do large numbers change value after formatting?
Does formatting change the order of my keys?
What happens if my JSON has duplicate keys?
What is a BOM, and why does it break my JSON?
What is NDJSON / JSON Lines, and can I format it here?
How do I handle dates in JSON?
My JSON is valid, but the API still rejects it — why?
Can I upload a .json file instead of pasting?
Generative Answer & AI Documentation
What is the JSON Formatter?
The JSON Formatter is an offline developer utility that cleans up, validates, and restructures JSON — minified single-line blobs, messy hand-written config, or raw API responses — into readable, properly indented data. Syntax errors are shown as the parser's message in a banner — no line or column is highlighted. It formats only: for the smallest possible payload, use the separate JSON Minifier. Formatting is cosmetic only; it never changes a value — though integer-like keys ("2", "10") are reordered numerically by the JavaScript parser, as explained in the FAQ below.
Why use JSON Formatter offline?
JSON is where secrets live: API responses carry tokens and user data, config files carry credentials and internal URLs, and production payloads carry customer records. Cloud formatters receive all of that over the network, and many log pasted input. An offline formatter runs the parse inside your browser's memory — nothing is uploaded, nothing is logged, and the page works with the network cable unplugged. For corporate developers handling client data, that is not a nice-to-have; it is the difference between a quick debug step and a data-handling incident.
When should you use this tool?
Use it whenever you need to read a JSON document a human was never meant to read: a minified API response in a bug report, a 2,000-line config file before editing it, a webhook payload from a log file, or a test fixture you're about to commit. Use the separate JSON Minifier tool when the JSON is headed for the wire — an API request body, a localStorage value, or a config file where every byte counts. Use the Validator instead when you only need a yes/no answer, and the Viewer when you need to explore a large response branch by branch.
Key Benefits
- 100% private: parsing runs in browser memory; no upload, no logs, no tracking.
- Clear error messages: a syntax error shows the parser's message in a banner — not a vague "invalid JSON" (though no line or column is highlighted).
- Indent control: 2 spaces, 4 spaces, or tabs, matching your project's style guide.
- Handles real payloads: large pasted API responses, including deeply nested ones. There is no file upload — paste the text.
- One direction, done well: format for humans. For the minified form, use the JSON Minifier.
- Zero friction: no signup, no install — paste JSON and click Format.
Common Use Cases
- Debugging API responses: copy a response from DevTools or Postman, format it, and read the actual structure instead of a single 40 KB line — then find the field your code is failing on.
- Fixing config files: package.json, tsconfig.json, .eslintrc, and CI configs are all JSON; one trailing comma breaks the whole build, and the error pointer finds it in seconds.
- Preparing test fixtures: format a captured production payload, trim it to the fields your test needs, and commit a readable fixture.
- Cleaning log output: webhook and structured-log JSON arrives minified; formatting it makes the one field you care about findable.
- Pre-flight checks before jq: a quick format-and-validate pass catches the syntax error before you debug a jq pipeline that was never the problem.
Developer Notes & Best Practices
The tool is a thin wrapper over the browser's own JSON engine: clicking Format runs JSON.parse on your input, then JSON.stringify with the indent you chose (2 spaces, 4 spaces, or a tab character). That parse-then-serialize round trip is the whole story, and it explains every quirk on this page. The output is a fresh serialization, not your original text with whitespace added, so anything the parser normalizes is normalized in the output: integer-like keys are reordered numerically, duplicate keys collapse to the last value, numbers beyond 2^53 lose precision, and insignificant whitespace is gone. Strings keep their content exactly, including escapes, and the output preserves the document's values — only the layout changes. On failure the tool shows the parser's own message (e.message) in a red banner and clears the output, so a failed format never leaves stale output on screen; an empty input gets its own message, "Please enter some JSON data." There is no file upload, no drag-and-drop, and no line or column highlight — the banner carries the message text only, and modern parsers include a character position ("at position 12") that you can count to from the start of the document. The page loads with a sample JSON document already in the input, and Reset restores it; a successful format can be copied or downloaded as formatted.json.
Error decoder
| Error message | Most likely cause | Fix |
|---|---|---|
| Unexpected token } | Missing comma, or an extra } | Check the previous line for a missing , |
| Unexpected token ' | Single-quoted string or key | Replace ' with " |
| Unexpected token / | A // or /* */ comment | Remove comments (or use JSONC tooling) |
| Unexpected end of JSON input | Truncated document | Check for a missing closing } or ] |
| Unexpected token o … at position 1 | Parsing [object Object] — stringified twice | Pass the object, not its string form |
| Error at position 0, text looks fine | UTF-8 BOM from a Windows editor | Re-save as UTF-8 without BOM |
Which JSON tool do you need?
| Tool | Question it answers | Output |
|---|---|---|
| Formatter | “Make this readable, and tell me if it's broken” | Indented JSON + error message |
| Validator | “Is this valid, yes or no?” | Verdict + error location |
| Minifier | “Make this as small as possible” | Single-line JSON |
| Viewer | “Let me explore this big response” | Collapsible syntax-coloured tree |
- Validate before committing a fixture or config — a broken package.json fails the whole install.
- Keep large IDs (Snowflake, database bigint keys) and money as strings; numbers above 2^53 lose precision silently.
- Minify payloads you store or transmit; format payloads humans read. Never ship pretty-printed JSON to production.
- When an API rejects valid JSON, diff your payload against its schema — wrong types and missing required fields are the usual cause, not syntax.
- Read the banner message, then count to its position: the parser names the offending character and its position, but nothing is highlighted, so paste the JSON into an editor, jump to that character offset, and look at the character just before it — the missing comma is usually there.
Common Mistakes
- Forgetting quotes around keys: standard JSON demands double quotes for all keys — {name: "Ada"} is JavaScript, not JSON.
- Using single quotes: JSON does not permit single quotes, only double quotes.
- Adding a trailing comma after the last property of an object or array.
- Writing NaN or Infinity: neither is valid JSON. Use null, or a string, or omit the field.
- Pasting a BOM-prefixed file: invisible at position 0 fails the parse even though the text looks perfect.
- Real newlines inside strings: a string value cannot contain a literal line break — it must be the escape .
- Missing commas between array items or object properties — the most common error after copy-pasting fragments together.
- Duplicate keys: the last value silently wins in most parsers, hiding a merge bug upstream.
- Assuming the error banner points at the line: it shows only the parser's message text, so use the position number in the message and count characters from the start — the highlighted line you expect does not exist.
- Pasting NDJSON (one JSON object per line) and expecting it to format: NDJSON is not a single JSON document, so format one line at a time, or wrap the lines in [ ... ] with commas between them first.
Limitations
Formatting is a parse-and-serialize round trip, so the output is never byte-identical to the input: integer-like keys are reordered numerically, duplicate keys collapse to the last value, and numbers beyond 2^53 lose precision — keep large IDs as strings if the exact digits matter. The tool checks syntax only; it does not validate against a JSON Schema, so a document can be perfectly valid JSON and still violate an API's contract. It parses strict JSON (RFC 8259): comments, trailing commas, single quotes, unquoted keys, NaN, and Infinity are all rejected, and there is no JSON5 or JSONC mode. Errors are reported as the parser's message in a banner only — no line or column is highlighted, and there is no click-to-jump to the error. There is no file upload or drag-and-drop; paste the text. Extremely large pastes may briefly freeze the tab while parsing, and pathologically deep nesting can hit parser stack limits.
Structured Input/Output Example
{"order_id":"ORD-90412","customer":{"name":"Ada Lovelace","email":"ada@example.com"},"items":[{"sku":"BAG-284","qty":2,"price":4900},{"sku":"BAG-305","qty":1,"price":4480}],"total":14280,"paid":true,"notes":null}{
"order_id": "ORD-90412",
"customer": {
"name": "Ada Lovelace",
"email": "ada@example.com"
},
"items": [
{
"sku": "BAG-284",
"qty": 2,
"price": 4900
},
{
"sku": "BAG-305",
"qty": 1,
"price": 4480
}
],
"total": 14280,
"paid": true,
"notes": null
}Related Tools
JSON Validator
JSON validator: paste JSON and click Validate for a verdict — valid or broken, with the line and column of the first syntax error. Strict RFC 8259.
JSON Schema Validator
Validate JSON data against a JSON Schema — does your object match the required shape? Every violation listed with its path and a fix hint. Free, offline.
JSON Minifier
JSON minifier: strip every unnecessary byte — whitespace, indentation, line breaks — values byte-identical. Shrink API payloads before they hit the wire.
JSON Viewer
JSON viewer for inspecting API responses as a collapsible, syntax-colored tree. Expand the branches you need, collapse the rest — free, 100% offline.
JSON to TypeScript
Convert any JSON object or array into clean TypeScript interfaces or type aliases in seconds — 100% offline, nothing uploaded.