How to use the JSON Formatter
- Paste your JSON into the left textbox. Formatting begins automatically after you stop typing for 300ms.
- Choose your indent: 2 spaces (default), 4 spaces, tab, or minified (single line).
- Read the result in the right textbox. On parse errors, the status line shows exact line and column.
- Click Copy to copy the output, or use
Ctrl/⌘ + Shift + C.
What makes a JSON document "valid"?
Per RFC 8259, a valid JSON document is
exactly one of: an object, an array, a string, a number, true, false, or null.
Trailing commas are not allowed. Comments are not allowed. Strings must be double-quoted — single quotes are
invalid JSON even if JavaScript accepts them.
Common JSON errors and what they mean
"Unexpected token" errors
Almost always one of these four:
- Trailing comma —
{"a":1,}is invalid. Remove the final comma. - Single quotes —
{'a':1}is invalid. Convert to double quotes. - Unquoted keys —
{a:1}is invalid. Wrap keys in double quotes:{"a":1}. - JavaScript values —
undefined,NaN, andInfinityare not valid JSON. Usenull.
"Unexpected end of JSON input"
Usually a missing closing brace, bracket, or quote. Look for unbalanced {}, [], or "".
"Bad control character in string literal"
Raw newlines, tabs, or other control characters in strings must be escaped: use \\n for newline, \\t for tab.
Privacy and performance
Parsing happens entirely in your browser via the built-in JSON.parse. No data is transmitted to any server.
The browser's native parser processes hundreds of kilobytes of JSON in single-digit milliseconds — much faster than
any "online formatter" that round-trips to a server. You can inspect the JavaScript running this tool via your
browser's DevTools.
Frequently asked questions
Does the JSON Formatter support JSON5 or JSONC (with comments)?
Not yet — this tool follows strict RFC 8259. JSON5 (with comments, trailing commas, single quotes) is planned as a separate mode. For now, if you paste JSON5, the error status will point at the offending character.
Can I format very large JSON files (100MB+)?
Browsers can parse JSON up to about 500MB before running into memory pressure, but the editor UI becomes
sluggish around 50MB of raw text. For multi-GB files, use a streaming parser like
jq or Node's stream-json.
Is the formatter deterministic?
Yes. For the same input and the same indent setting, output is byte-identical across runs and browsers.
Object key order is preserved as in the input (modern JSON.stringify respects insertion order).
Why does my JSON look different after formatting?
The formatter normalizes whitespace and preserves everything else. Numbers are re-serialized via
JSON.stringify, which means 1.0 in the input becomes 1 in the output
(both are the same number in JSON). Unicode escapes like \\u00e9 are converted to the
corresponding character (é) when that character is safely printable.
Can I use this offline?
Once the page has loaded, yes — everything runs in-browser. You can disconnect from the internet and the tool keeps working. Add the page to your bookmarks or use your browser's "install as app" option for one-click access.
Related tools
- Base64 Encoder / Decoder — Encode and decode Base64 strings and files. Client-side, safe for sensitive data.
- XML Formatter — Format, validate, and beautify XML documents.
- YAML ↔ JSON Converter — Convert between YAML and JSON formats with full fidelity.
- CSV to JSON Converter — Convert CSV files to JSON with proper quoting and escaping.
- JSON Diff — Compare two JSON objects structurally with field-by-field diff.
Further reading
- What Is JSON and Why You Should Always Format It
- The 10 Most Common JSON Validation Errors (and How to Fix Them)
Pillar
Part of Data & Format — JSON, YAML, XML, CSV, SQL, Markdown utilities.
Written and maintained by Mian Ali Khalid. Last updated 2026-04-25.