All Tools

JSON Formatter and Validator, Free and Private

Format, minify and validate JSON in your browser. Pick 2 spaces, 4 spaces or tabs, sort keys, and see errors with the line, column and offending text. Big numbers stay exact. Nothing is uploaded.

Layout

Orders object keys alphabetically at every level.

Removes comments and trailing commas before parsing.

0 characters, 0 bytes

0 characters, 0 bytes


About the JSON Formatter

The JSON Formatter turns compact or messy JSON into readable, indented text, shrinks it back down again, and tells you exactly where it is invalid. Paste your JSON on the left and the result appears on the right as you type. Choose 2 spaces, 4 spaces or Tab for indentation, Minified to remove every unnecessary character, or Validate only to check the text without producing any output.

Your JSON never leaves your device. The text is read in the page by plain JavaScript, so nothing is uploaded, logged or stored, and it is gone when you close the tab. That makes it fine for API responses, config files and logs that you would rather not paste into a website that sends them to a server.

How to use it

Steps

  1. Paste or type JSON into JSON.
  2. Pick a Layout. The default is two spaces.
  3. Turn on Sort keys if you want object keys in alphabetical order, which makes two documents easy to compare.
  4. Read the note under the result: it says the input is valid, its size in bytes before and after, and how much smaller or larger the result is.
  5. Press Copy or Download .json to take the result with you.

Errors that say where

When the text is not valid JSON, the tool does not just say "unexpected token". It reports the line and column of the first problem, says what is wrong in plain words, and shows the offending line with a caret under the exact character. For {"a": 1,} the message is Line 1, column 8: Trailing comma before "}". The common mistakes each get their own message: single quotes instead of double quotes, comments, missing commas, unquoted keys, raw line breaks inside strings, leading zeros and invalid escapes.

Repair is off by default

Comments and trailing commas are not valid JSON, but they are common in configuration files written by hand. Turn on Repair and the tool skips comments and accepts one trailing comma before a closing bracket, then tells you how many of each it removed. It is off by default so that a strict check stays strict: a validator that quietly accepts broken input is not a validator.

Big numbers stay exact

JavaScript stores every number as a 64-bit float, so integers above 253−1=90071992547409912^{53} - 1 = 9007199254740991 lose digits when parsed the usual way. This tool keeps each number as the text you wrote, so 12345678901234567890 comes out as 12345678901234567890, and 1.0 stays 1.0. The note tells you when it kept such an integer exactly.

Worked example

Input:

{"name":"Ada","tags":["math","code"],"id":12345678901234567890}

With two spaces the result is:

{
  "name": "Ada",
  "tags": [
    "math",
    "code"
  ],
  "id": 12345678901234567890
}

The input is 65 bytes. The formatted output is longer, because indentation adds characters, and the note says so. Choose Minified and the same document comes back at its smallest size with no spaces after colons or commas.

Limits

Duplicate keys are kept in the order they appear, since JSON does not forbid them and dropping one would change your data. With Sort keys on, keys are ordered by their UTF-16 code units, so uppercase letters sort before lowercase and the result does not depend on your language settings. Nesting deeper than 1000 levels is reported as an error rather than freezing the page. To explore a large document instead of reading it line by line, open the JSON Viewer, and to compare two versions use the Text Diff tool.

Frequently asked questions

Is my JSON sent to a server?

No. Formatting, minifying and validating run in your browser, so the text is not uploaded, logged or stored. Closing the tab clears it. Even so, avoid pasting live secrets such as passwords or private keys into any online tool you cannot inspect.

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

JSON is stricter than JavaScript. It needs double-quoted keys and strings, and it forbids comments, trailing commas and values such as undefined or NaN. The error names the line and column, and Repair can remove comments and trailing commas if that is all that is wrong.

What does Repair do?

It skips // and /* */ comments and accepts one trailing comma before a closing bracket or brace, then tells you how many of each it removed. It is off by default so that the validator stays strict. It does not fix single quotes, missing commas or unquoted keys.

Are large numbers changed?

No. Each number is kept as the text you wrote, so integers above 9007199254740991 keep every digit and 1.0 stays 1.0. Most online formatters parse numbers into floating point and silently round big IDs, which this tool avoids.

Does Sort keys change my data?

It changes the order of keys inside objects, ordered by UTF-16 code units, and nothing else. Array items are never reordered. Sorting makes two versions of a document easier to compare line by line.

What happens to duplicate keys?

They are kept, in the order they appear. JSON does not forbid duplicates, and most parsers keep only the last one, so removing one here would hide a problem in your data instead of showing it.

Other related tools