When to use a JSON formatter
Most of the time you want a JSON formatter, you already have JSON — it's just in a shape you can't read. Common cases:
- An API response came back minified as a single line and you need to find one field buried eight levels deep.
- A config file got edited by a tool that stripped whitespace, and you want to see the structure before you can diff it.
- You're pasting a payload into a bug report and you want the reviewer to read it in five seconds, not fifty.
- You copied a snippet from a log line and want to confirm it's actually valid before sending it anywhere.
A formatter solves the first three. A validator solves the last. This tool does both: paste once, click Format to beautify, Validate to check for errors, or Minify to collapse it back.
Common JSON errors and how to fix them
The browser's JSON.parse() strictly follows RFC 8259, which is why it's picky about things you might consider minor. The good news: every error message maps to a specific fix.
Unexpected token , in JSON at position N
A trailing comma — legal in JavaScript object literals, illegal in JSON.
{
"name": "ada",
"age": 36,
} Remove the comma after 36.
Unexpected end of JSON input
A bracket, brace, or string was opened and never closed.
{ "items": [1, 2, 3 } The array opened with [ but never closed. Usually a hand-edit or a copy-paste that clipped one line. Close the array, then the object.
Unexpected token ' in JSON at position 0
Single quotes where double quotes are required.
{ 'name': 'ada' } JSON requires double quotes for both keys and string values. Most editors will swap them in one find-and-replace.
Bad control character in string literal
A raw newline, tab, or other control character inside a string.
{ "message": "line one
line two" } Escape the newline with \n:
{ "message": "line one\nline two" } Unexpected token a in JSON at position 0
You pasted a JavaScript object literal instead of JSON.
{ name: "ada", age: 36 } Valid JavaScript, invalid JSON — the keys aren't quoted. Wrap every key in double quotes.
Strict JSON vs JSON5 vs JSONC
If you're frequently working with JSON that has comments or trailing commas, you're not working with strict JSON — you're working with a relaxed variant:
- JSON5 — allows comments, trailing commas, unquoted keys, single quotes, and hex numbers. Used by Babel, Parcel, and some database config files.
- JSONC (JSON with Comments) — adds line and block comments. Used by VS Code's
tsconfig.jsonandsettings.json. - HJSON — human-oriented dialect with unquoted values and comments. Rare outside its own ecosystem.
This formatter targets strict JSON only. If you need to work with JSON5 or JSONC, strip the relaxed syntax first, or use a parser built for that variant.
How this formatter handles large files
The formatter runs entirely in your browser using JSON.parse() and JSON.stringify(). There's no upload and no server round-trip, which means:
- No size limit from us. The practical ceiling is whatever your browser tab can allocate — typically several hundred megabytes before you hit memory pressure on desktop.
- Validate and Format are the same work. Both build the full object tree. There's no "light validator" that avoids the parse cost.
- Sensitive data never leaves. API responses with auth tokens, database dumps, user PII — all stay on your machine. This is the whole reason the tool exists.
If your JSON is genuinely enormous (a 500 MB log export, for example), a streaming parser like stream-json in Node or jq -c on the command line will serve you better than any browser-based tool, ours included.
Keyboard workflow
The tool is designed for paste-in, format, copy-out:
- Ctrl/Cmd+A in the input to select everything, then paste your JSON over the top.
- Click Format to beautify, or Minify to collapse.
- Ctrl/Cmd+A on the output, Ctrl/Cmd+C to copy.
If you work with curl a lot, piping a response straight to your clipboard means you can paste it into the formatter in one step: curl -s URL | pbcopy on macOS, or curl -s URL | xclip -sel clip on Linux.
Related JSON tools on CodeBoxTools
This formatter is the entry point to a cluster of JSON tools on the site:
- JSON Diff — compare two JSON objects and see exactly which keys changed, with paths.
- JSON to CSV — export a JSON array as a spreadsheet with flattened nested keys.
- JSON to YAML and YAML to JSON — round-trip between formats.
- JSON to TypeScript — generate type definitions from a sample payload.
- JSON to XML — structural conversion with attribute handling.