Home / Free tools / Text & Data / JSON Formatter and Validator

JSON Formatter and Validator

Paste JSON to check it, tidy it or squeeze it onto one line. Errors show the line and column. Big numbers and key order are kept exactly as written. Nothing leaves your browser.

Runs in your browser. Nothing you paste or choose is uploaded or stored.

What this JSON formatter does

This tool reads JSON text, tells you whether it is valid, and rewrites it with tidy indentation or squeezed onto one line. If the text is not valid it points at the exact line and column where the problem starts, and an optional repair button fixes the mistakes people make most often when they write JSON by hand. It runs entirely in your browser, so API responses, configuration files and product data can be pasted without being uploaded anywhere.

JSON (JavaScript Object Notation) is the plain-text format most web services use to exchange data. It is defined in RFC 8259 and is deliberately small: objects in curly braces, arrays in square brackets, strings in double quotes, numbers, true, false and null. Because the rules are so strict, one stray comma is enough to make a program reject the whole document, which is why a validator that shows the position of the error saves so much time.

The rules this validator enforces

Big numbers and repeated keys

Most tools that format JSON parse it into a JavaScript object and print it again. That quietly changes data: any integer larger than 9,007,199,254,740,991 is rounded, and a key that appears twice keeps only its last value. This formatter reads the text with its own parser instead and keeps your numbers exactly as written, so an order number such as 12345678901234567890 comes out unchanged. It also warns you when it meets a number too large for JavaScript or a repeated key, because the program that eventually reads your data may not be so careful.

Worked example

Press "Load an example" to see a small product record. The input is a single line, {"sku":"MUG-01","price":12.5,"tags":["kitchen","gift"],...}. After Format with two spaces the same data is spread over lines with each key on its own line and the tags array indented below it. Nothing about the values changes: the GTIN "0012345678905" stays a string with its two leading zeros, and 12.5 stays 12.5. As a second test, paste {"id":12345678901234567890,"a":1,"a":2}. The output keeps the long number exactly and shows two warnings: one for the integer larger than 9,007,199,254,740,991 and one for the duplicate key a.

What "Try to repair" fixes

The repair button handles the mistakes that appear when JSON is typed or copied from code: comments, trailing commas, single-quoted strings, unquoted keys and the Python words True, False and None. It tells you each fix it made. It does not guess at damaged structure such as a missing bracket, because a guess could change your data without telling you; for those cases the error message shows where to look. Always read repaired output before you use it.

Tips for working with JSON

Privacy and limits

Your JSON is processed in the page and is not uploaded, stored or added to the address bar. Files up to 20 MB open directly; very large documents depend on your device's memory, and nesting deeper than 1,000 levels is rejected to protect the browser. More of the free tools on this site are listed under Text and data.

Questions

How do I check whether my JSON is valid?

Paste it and press Validate only or Format. A valid document shows a green message with the number of objects, arrays and keys it contains. An invalid one shows what is wrong and the line and column where the parser stopped, and a button that selects that spot in your text.

Why does the validator say my JSON is invalid when it works in my code?

Many languages accept things that standard JSON forbids: single quotes, unquoted keys, trailing commas, comments, NaN and undefined. This tool follows RFC 8259, which is what most strict parsers and web APIs expect. The Try to repair button fixes the usual cases.

Does formatting change my data?

No. The formatter keeps keys in their original order, keeps numbers exactly as you wrote them, including very large integers and trailing zeros such as 12.50, and only changes whitespace. The one optional exception is Sort keys, which reorders keys on purpose.

What happens to numbers larger than JavaScript can hold?

They are kept exactly as written and the tool shows a warning. A program that reads the data with ordinary JavaScript would round them, so store such identifiers as strings.

Is my JSON uploaded anywhere?

No. Parsing, formatting and repair all happen in your browser. The text is not sent to a server, not saved and not placed in the page address.

How big a file can it handle?

Files up to 20 MB can be opened. Speed then depends on your device; a few megabytes format in well under a second on an ordinary laptop. Documents nested more than 1,000 levels deep are rejected.

Can it handle JSON with comments, like a tsconfig or VS Code settings file?

Press Try to repair. It removes comments and trailing commas and reports what it removed. The result is standard JSON, so the comments are lost; keep your original file if you need them.

Google, Merchant Center, YouTube, LinkedIn, Indeed, Glassdoor and Shopify are trademarks of their owners. Van Born Labs is independent and not affiliated with them. Google's own help pages are the final word on its rules.