JSON Formatter & Validator
Runs entirely in your browser. Nothing is uploaded. No limits, no signup.
Quick answer: paste your JSON into the formatter above and press Beautify. Valid JSON comes back indented and colour-coded. Invalid JSON gets an error message with the line, column and the text around the problem. Processing happens in your browser, so nothing you paste is uploaded.
JSON usually arrives in one of two states: squashed onto a single line by whatever produced it, or broken by one stray character. A formatter fixes the first and points at the second. This guide covers what the formatter does, the errors it catches most often, and two things it can quietly change in your data that are worth knowing before you paste in anything important.
What JSON is
JSON (JavaScript Object Notation) is a text format for structured data. It grew out of JavaScript's object syntax, but it is defined independently of any language in RFC 8259 and the ECMA-404 standard, and nearly every programming language can read and write it.
It has two containers. Objects hold key and value pairs inside curly braces, and arrays hold ordered lists inside square brackets. A value can be a string in double quotes, a number, true, false, null, or another object or array:
{
"name": "Alex",
"active": true,
"roles": ["admin", "editor"],
"profile": {
"age": 34,
"city": "London"
}
}
Beautify, minify and validate
Beautify (also called format or pretty-print) puts each key and value on its own line and indents each level of nesting. Pick 2 spaces, 4 spaces or a tab. Use it for reading an API response, reviewing a config file or comparing two versions of the same data.
Minify removes every space and line break that is not inside a string. The example above shrinks from 138 bytes to 93, about a third smaller:
{"name":"Alex","active":true,"roles":["admin","editor"],"profile":{"age":34,"city":"London"}}
Savings depend on how deeply the data is nested. If a server already compresses its responses with gzip or Brotli, the difference on the wire is much smaller than the raw byte count suggests, because whitespace compresses very well.
Validate only checks the syntax and reports the root type (object or array) and the total number of keys, without changing your input.
The errors that break JSON most often
JSON is stricter than the JavaScript it came from, and almost every validation error is one of these five. The messages in quotes are what Chrome and Edge report; Firefox and Safari word them differently.
A trailing comma
JavaScript allows a comma after the last item in an object or array. JSON does not. {"a": 1, "b": 2,} fails with "Expected double-quoted property name". The pointer lands on the closing brace, one character after the actual mistake.
Single quotes
Keys and strings must use double quotes. {'name': 'Alex'} is valid JavaScript and invalid JSON.
Unquoted keys
{name: "Alex"} fails for the same reason. Every key has to be a double-quoted string.
Comments
Neither // nor /* */ is allowed. Some tools accept comments in their own config files (VS Code's settings and TypeScript's tsconfig.json both do), but that is a relaxed variant often called JSONC, and a strict parser like this one will reject it. Delete the comments before validating.
Missing or mismatched brackets
Every { needs a } and every [ needs a ]. In deeply nested data the parser often notices the problem well after the real mistake, so if the pointer seems wrong, look backwards for the last place the nesting changed.
When the browser reports where an error is, the formatter shows the line, the column and about 20 characters either side of it, with a marker at the failure point.
Two things a formatter can change
Like nearly every browser-based formatter, this one reads your JSON with JavaScript's JSON.parse() and writes it back out with JSON.stringify(). That round trip is faithful for almost all data, with two exceptions.
Very large integers get rounded. JavaScript stores every number as a 64-bit float, which can only represent whole numbers exactly up to 9,007,199,254,740,991. Anything bigger is rounded to the nearest value it can store:
input: {"id": 12345678901234567890}
output: {"id": 12345678901234567000}
This matters for database IDs, order numbers and some social media post IDs, which are often 18 or 19 digits long. The formatter warns you when it detects a long integer that changed. If you need the original digits, have the system that produces the JSON send those IDs as strings.
Duplicate keys collapse. RFC 8259 says keys within an object should be unique, but it does not forbid duplicates, so {"a": 1, "a": 2} is technically valid. JavaScript keeps the last one and the output is {"a": 2}. Other parsers may keep the first, so if your data has duplicates, fix them at the source.
Privacy and safety
JSON often contains things you would not want to paste into a stranger's server: API keys, session tokens, customer records, database credentials. Some online formatters process input on their servers. This one does all of its work in your browser tab, and you can check that by opening the developer tools, switching to the Network tab and pressing Beautify. No request is made. Once the page has loaded, it keeps working with your internet connection switched off.
The formatter also escapes your input before adding syntax colours. If your JSON contains HTML or a <script> tag, it is displayed as plain text and never run in the page. That protects you from cross-site scripting when you paste data you did not write yourself.
Frequently asked questions
Is it safe to format JSON online?
It depends on where the processing happens. This formatter runs entirely in your browser, so the JSON never leaves your device. Avoid pasting secrets into any tool that sends input to a server.
Why is my JSON invalid?
The usual causes are a trailing comma after the last item, single quotes instead of double quotes, keys without quotes, comments, and missing or mismatched brackets.
Why did a long number change after formatting?
JavaScript can only store whole numbers exactly up to 9,007,199,254,740,991. Larger integers are rounded when the JSON is parsed. Send large IDs as strings to keep every digit.
Can JSON contain comments?
No. Standard JSON has no comment syntax. Some tools accept a relaxed variant with comments, called JSONC, but strict parsers reject it.
Does the formatter work offline?
Yes, once the page has loaded. All processing is local JavaScript.