Loading…

JSON Formatter & Validator

Paste your JSON to format, validate, minify or repair it in one click. Errors are shown with the exact line and column, a collapsible tree lets you explore large documents, and big numbers keep every digit. Everything runs in your browser, so your data never leaves your device.

  • Free
  • No sign-up
  • Runs in your browser
  • Private: nothing is stored

Last updated

How to use the JSON Formatter

  1. Paste your JSON into the Input box, drop a .json file onto it, or click Sample.
  2. The result appears on the right. Choose Format, Minify or Repair, and pick your indentation.
  3. If there is an error, read the message, click Go to error, or click Repair it to fix common mistakes automatically.
  4. Switch to the Tree tab to explore the data, then Copy or Download the result.

Why use this tool

  • Clear error messages with line and column, plus a hint on how to fix them.
  • Repair mode fixes comments, trailing commas, single quotes, unquoted keys and more.
  • Exact numbers: large integers and decimals are never rounded or changed.
  • Collapsible tree view. Click any key to copy its JSONPath, such as $.users[0].name.
  • Sort keys, choose 2, 3, 4 spaces or tabs, and download the result.
  • Private: your JSON is processed locally and never uploaded.

What is JSON?

JSON (JavaScript Object Notation) is a lightweight text format for storing and exchanging data. It is the standard way web APIs send data to apps and websites, and it is also used for configuration files, databases and logs. It is easy for people to read and easy for programs to parse.

A JSON document is built from just two structures: objects (a set of named values inside curly braces) and arrays (an ordered list of values inside square brackets). Here is a small example:

{
  "name": "Wabten",
  "free": true,
  "tools": ["json", "password"],
  "owner": { "name": "A. Example", "email": null }
}

JSON syntax rules

  • Data is written as name and value pairs, separated by a colon: "name": "value".
  • Names (keys) must be in double quotes. Single quotes are not allowed.
  • Values can be a string, a number, true, false, null, an object or an array.
  • Items in an object or array are separated by commas, with no comma after the last item.
  • Strings use double quotes. Line breaks and tabs inside a string must be written as \n and \t.
  • Comments, undefined, NaN and Infinity are not part of standard JSON.

Format, validate or minify: which should you use?

  • Format (beautify) adds indentation and line breaks so humans can read the data. Use it when you are debugging an API response or reading a config file.
  • Validate checks that the text is correct JSON and tells you exactly where the first problem is. Use it before sending data to an API or saving a config file.
  • Minify removes every unnecessary space and line break to make the data as small as possible. Use it to reduce the size of data you send or store.
  • Sort keys puts the keys of every object in alphabetical order, which makes two documents easier to compare.

Common JSON errors and how to fix them

Most invalid JSON comes from a handful of mistakes. This table shows what each looks like and how to fix it. The formatter points to the exact line and column, and Repair can fix many of them for you.

ProblemExampleHow to fix it
Trailing comma{"a": 1,}Remove the comma after the last item
Single quotes{'a': 1}Use double quotes around keys and strings
Unquoted key{a: 1}Wrap the key in double quotes: {"a": 1}
Comment{"a": 1} // noteRemove the comment (JSON does not support them)
Missing comma{"a": 1 "b": 2}Add a comma between the two items
Missing bracket or brace{"a": [1, 2}Add the missing closing ] or }
Invalid value{"a": undefined}Use null instead of undefined, NaN or Infinity
Raw line break in a stringa string split over two linesWrite the line break as \n

Fix broken JSON with Repair

Repair reads JSON the way a forgiving human would and writes it back as strictly valid JSON. It can remove comments, delete trailing commas, convert single quotes to double quotes, add missing quotes around keys, escape raw line breaks inside strings, and replace Python-style True, False and None, as well as undefined, NaN and Infinity, with valid JSON values. After a repair, the tool lists exactly what it changed so you can check it.

Repair cannot guess missing data. If a bracket, brace or quote is missing, or two values have no separator, you will still see an error with its location so you can fix it by hand.

Why exact numbers matter

Many tools read JSON with JavaScript’s built-in parser, which stores every number as a 64-bit floating point value. That silently changes any whole number above 9,007,199,254,740,991 and can alter decimals. The number 12345678901234567890 becomes 12345678901234567000, which corrupts IDs, order numbers and timestamps.

This formatter does not convert numbers at all. It keeps each number exactly as you wrote it, including 1.0, 1E+5 and very large integers, so formatting and minifying never change your data.

Working with JSON in code

Every major language can read and write JSON. In JavaScript, JSON.parse() turns text into a value and JSON.stringify() turns a value back into text. The third argument of stringify sets the indentation:

const data = JSON.parse(text);
const pretty = JSON.stringify(data, null, 2); // 2-space indent
const compact = JSON.stringify(data);          // minified

In Python, use the built-in json module: json.loads(text) to read and json.dumps(data, indent=2) to write. In PHP, use json_decode() and json_encode() with the JSON_PRETTY_PRINT flag.

Is it safe to paste my JSON here?

Yes. All parsing, formatting and repairing happen in your browser. Your JSON is not uploaded, logged or stored, and the tool keeps working if you switch off your connection after the page has loaded. Even so, avoid pasting live passwords, API keys or private tokens into any website.

JSON Formatter FAQ

Paste your JSON into the Input box. It is formatted automatically with the indentation you choose (2, 3 or 4 spaces, or tabs). You can also press the Format button, then copy or download the result.
If your JSON is invalid, the tool shows what is wrong together with the line and column number, highlights the line in the gutter, and shows a hint on how to fix it. Click Go to error to jump to that spot.
Yes, for common mistakes. Repair removes comments and trailing commas, converts single quotes, quotes unquoted keys, escapes raw line breaks in strings and replaces Python or JavaScript values such as None, True, undefined and NaN. It cannot invent missing data, so structural problems such as a missing bracket must be fixed by hand.
Format adds indentation and line breaks to make JSON readable. Validate checks that the JSON is correct and reports the first error. Minify removes all unnecessary whitespace to make it as small as possible.
It usually means a character is not allowed at that position. Common causes are a trailing comma, single quotes, an unquoted key, a comment or a missing comma between two items. The error message here names the exact problem and its location.
No. Numbers are kept exactly as written, so large integers such as 12345678901234567890 and values like 1.0 or 1E+5 are never rounded or rewritten.
You can open files up to 20 MB. Very large documents are shown as plain text, without colour, to keep the page fast, and the tree view loads large lists in batches of 100 items.
Not in standard JSON. Some tools accept comments (the JSONC and JSON5 variants), but a standard parser will reject them. Use Repair to strip comments before sending the data to a standard JSON parser.
It reorders the keys of every object alphabetically, at every level. Arrays keep their order. Sorted output makes it much easier to compare two JSON documents.
No. Everything is processed locally in your browser. We never receive or store your JSON.