JSON Formatter
Paste your JSON below to format, validate and make it easier to read. This tool runs in your browser and does not upload your input.
Updated July 11, 2026
100% Private & Secure
This tool runs in your browser.
Your data is never uploaded or stored.
Click Format or Minify to see resultsHow to use
- 1
Paste your JSON into the input box.
- 2
Click Format to beautify and validate it.
- 3
Copy the formatted output when you are done.
When to use it
Debugging a failing API request
When a fetch returns something unexpected, paste the raw response body and format it. The indented tree makes it obvious which field is missing, mistyped, or nested one level too deep.
Reading minified or single-line config
Files like package-lock.json, Terraform state, or a one-line API payload are unreadable as-is. Formatting turns them into navigable, structured output you can actually scan.
Validating before a deploy
Catching a stray trailing comma or unquoted key locally is far cheaper than discovering it when your config loader throws in production.
Sharing snippets in reviews and docs
Consistently indented JSON reads cleanly in pull requests, READMEs, and bug reports — and copy-pastes without reflowing.
How it works
What JSON actually is
JSON (JavaScript Object Notation) is a text interchange format defined by RFC 8259. It has exactly six data types: object, array, string, number, boolean, and null. Despite the name, JSON is not a subset of JavaScript syntax — it is its own, stricter grammar.
Strings must use double quotes; object keys must be quoted; there are no comments, no trailing commas, and no bare NaN or Infinity. That strictness is the point: any compliant parser, in any language, reads the same bytes the same way.
-
{}object and[]array — named and ordered collections - Numbers are IEEE 754 double precision — integers lose precision past 253
-
true,false, andnullare the only literals
Valid JSON is not always valid JavaScript
A common trap: text that runs fine in a .js file makes JSON.parse throw. The three usual suspects are single-quoted strings, unquoted keys, and trailing commas — all legal JavaScript, all illegal JSON.
There is also the subtler U+2028 / U+2029 case: these line separators are valid inside JSON strings but were invalid in JavaScript string literals before ES2019. This is why you should never eval() JSON — always parse it.
// Valid JavaScript, INVALID JSON — JSON.parse throws on all three:
{ 'key': 'value', } // single quotes + trailing comma
{ key: "value" } // unquoted key How pretty-printing works under the hood
Indentation comes from JSON.stringify(value, replacer, space). The third argument controls spacing — pass 2 for two spaces, or "\t" for tabs. The second argument is a replacer: a function to filter or transform values, or an array of keys to whitelist.
For very large payloads (multi-megabyte logs), formatting has a real memory cost because the entire structure is serialized into a new string. Validate first, format second, and reach for a streaming parser when input is huge.
Common mistakes & edge cases
"Unexpected token } in JSON" or trailing characters after the document
Almost always a trailing comma after the last item. JSON forbids trailing commas — remove it.
"Unexpected token ' in JSON" — strings wrapped in single quotes
JSON requires double-quoted strings. Switch every ' to " on both keys and values.
"Unexpected token k in JSON" — an unquoted object key
Keys must be double-quoted. { name: "x" } is JavaScript; { "name": "x" } is JSON.
// or /* */ comments cause a parse error
Plain JSON has no comments. If you need them, use JSONC or JSON5 — but standard JSON.parse will reject them.
Frequently Asked Questions
Is my JSON uploaded to a server?
Can this tool validate invalid JSON?
What is JSON formatting?
References & further reading
Related reading
Structured data (JSON-LD) for tool sites
How JSON-LD unlocks rich results, the schema types a tool site needs (WebApplication, FAQPage, BreadcrumbList), and a working example.
Why Won't My JSON Parse? A Field Guide to the Common Errors
The seven JSON errors that break parsers every day — trailing commas, unquoted keys, comments, BOM — each with the broken input, the error, and the fix.
YAML vs JSON vs CSV: picking the right data format
Three config-and-data formats, compared on strictness, comments, and the indentation trap that breaks YAML at scale.