JSON Formatter & Validator

Format, validate and minify JSON, with exact line and column errors.

Checked in your browser. Your JSON is never uploaded, saved or put in the page link.

Examples

Output

Result

Valid JSON

Valid JSON (1 object, 1 array, 5 keys), formatted with 2 spaces.

Output

{
  "name": "Ada Lovelace",
  "born": 1815,
  "languages": [
    "en",
    "fr"
  ],
  "active": true,
  "spouse": null
}
Input size
87 bytes
Output size
121 bytes (+39.1%)
Nesting depth
2 levels
Keys
5
Values (strings, numbers, true/false/null)
6

Fix the highlighted field to update the result.

How to use

  1. Paste your JSON into the box. It is checked as you type.
  2. Choose Format (2 spaces, 4 spaces or tabs) or Minify, and optionally sort the keys A → Z.
  3. If the JSON is invalid, read the line, column and reason, fix that spot, and the result updates.
  4. Press Copy JSON to take the output.

Your JSON never leaves your browser, so API keys and customer data stay private.

How the validator works

JSON is defined by RFC 8259 and ECMA-404. A JSON text is one value: an object {}, an array [], a string in double quotes, a number, true, false or null. The rules people trip over most:

  • No trailing commas after the last item.
  • Double quotes only, for both names and strings.
  • No comments, and no NaN, Infinity or undefined.
  • No leading zeros in numbers: write 7, not 07.

The checker reads the text character by character, so it can point at the first problem. Numbers and strings are copied exactly as typed, so nothing is rounded.

Example

This input has trailing commas:

{
  "name": "Ada",
  "skills": ["math", "poetry",],
}

The checker reports line 3, column 31: trailing comma, remove the comma before “]”. Fix it, and the one after ], and the JSON is valid.

Formatting the sample object (87 bytes minified) with 2-space indents gives 10 lines and 121 bytes. Minifying removes those 34 bytes again; the data is identical.

Big numbers, duplicate keys and other details
  • Big numbers: JavaScript’s JSON.parse rounds 12345678901234567890 to 12345678901234567000, because doubles are exact only up to 9,007,199,254,740,991. This formatter keeps the digits as written.
  • Duplicate keys are allowed by the grammar, but RFC 8259 says names SHOULD be unique. You get a warning, because programs disagree on which value wins.
  • Sorting orders keys by character code (uppercase before lowercase), at every level. Arrays keep their order.
  • Nesting is limited to 1,000 levels, as RFC 8259 allows parsers to do.

Need to send the JSON inside a link? The Base64 encoder or the URL encoder will make it safe to paste.

Frequently asked questions

Is my JSON sent to a server?

No. Formatting and validation run entirely in your browser. Your JSON is never uploaded, never added to the page link and never saved.

Why is my JSON invalid?

Usually a trailing comma, single quotes, an unquoted name, a comment or a missing comma. The error gives the line, column and reason for the first problem.

Does JSON allow comments or trailing commas?

No. Standard JSON (RFC 8259) has neither. Variants such as JSON5 add them, but strict parsers, including JavaScript’s JSON.parse, reject them.

Why do big numbers change in some JSON tools?

Many tools convert numbers to JavaScript doubles, which are exact only up to 9,007,199,254,740,991. This formatter keeps every number exactly as typed.

Are duplicate keys allowed in JSON?

The grammar allows them, but RFC 8259 says names SHOULD be unique. Programs disagree on which value wins, so we keep both and show a warning.

What is the difference between formatting and minifying?

Formatting adds line breaks and indentation so people can read it. Minifying removes every optional space and line break. The data is identical either way.

Embed this calculator

Add this calculator to your own website for free. Copy the code below and paste it into your page’s HTML. The attribution link is optional.