Free tool

JSON formatter & validator

Format, validate and minify JSON instantly, with clear error messages.

Loading tool…

How to use the json formatter

01

Paste JSON

From an API, file or log.

02

Format or minify

2 or 4 space indentation, or one line.

03

Copy

Copy the result.

What does the JSON formatter do?

Format (pretty-print) adds line breaks and indentation so nested data is easy to read. Minify removes all unnecessary whitespace to make the smallest possible text, which is useful for APIs and config files. Validate checks the syntax and shows the first error it finds.

Everything runs in your browser, so you can safely paste API responses and config files that contain private data.

Why is my JSON invalid?

  • A trailing comma after the last item in an object or array
  • Single quotes instead of double quotes around keys and strings
  • Unquoted keys, which are valid in JavaScript but not in JSON
  • Comments, which JSON does not allow
  • Values such as undefined, NaN or Infinity, which JSON does not support
  • Missing or extra brackets and braces

JSON basics

JSON has six value types: objects, arrays, strings, numbers, true or false, and null. Keys must be double-quoted strings. Because it is plain text and readable by almost every language, it has become the standard format for web APIs and configuration.

Example: before and after

Minify reverses the process, collapsing the data back to a single compact line.

Before:  {"name":"Ada","skills":["math","code"],"active":true}

After formatting (2 spaces):
{
  "name": "Ada",
  "skills": [
    "math",
    "code"
  ],
  "active": true
}

JSON compared with YAML and XML

FormatCommentsBest for
JSONNot allowedAPIs and data exchange
YAMLAllowedConfiguration files people edit by hand
XMLAllowedDocuments and older enterprise systems
FAQ

JSON Formatter FAQ

Free, private and browser-based. Your data never leaves your device.

Is my JSON sent to a server?

No. Parsing happens in your browser.

Why is my JSON invalid?

Common causes: trailing commas, single quotes instead of double quotes, or unquoted keys.

Can it handle large JSON files?

It handles files of several megabytes. Very large files may slow your browser tab because everything is processed locally.

Does formatting change my data?

No. Only whitespace changes and key order is preserved. One caution: integers larger than 9,007,199,254,740,991 can lose precision, because JavaScript reads them as floating-point numbers.

How many spaces should I indent with?

Two spaces is the most common choice for web projects, and four is common in other ecosystems. Pick whichever matches your project’s style.

Can I paste JSON that contains comments?

Standard JSON does not allow comments, so the validator reports an error. Remove the comments, or use a format such as JSON5 or YAML if you need them.

Related

More developer tools