JSON formatter and validator

Paste JSON to pretty print, minify or check it. Errors show the exact line and column. Runs in your browser; nothing is uploaded.

Tip: Ctrl+Enter (Cmd+Enter on a Mac) formats.

How to use the JSON formatter

  1. Paste JSON into the input box, or press Open file to load a .json file from your computer. The file is read by your browser, not uploaded.
  2. Choose an indent (2 spaces, 4 spaces or tabs) and, if you want, tick Sort keys A to Z.
  3. Press Format to pretty print, Minify to strip whitespace, or Validate to only check it.
  4. Switch to Tree to fold and unfold objects and arrays, then Copy or Download the result.

Reading the error messages

When JSON is invalid, the formatter stops at the first problem and tells you where it is, for example "Line 3, column 30: Trailing comma is not allowed". Lines and columns count from 1, and a tab counts as one column. The line is shown with a caret under the character, and Go to error selects it in the input so you can fix it. This text has two trailing commas, which most JavaScript code accepts but JSON does not:

{
  "name": "Ada",
  "tags": ["admin", "editor",],
}

The most common mistakes, and what to do about them:

What JSON is

JSON (JavaScript Object Notation) is a plain-text format for structured data. It is defined by RFC 8259 and ECMA-404 and is used by almost every web API, many configuration files and most databases that store documents. A JSON value is one of six kinds:

Whitespace between those pieces (spaces, tabs, line breaks) has no meaning, which is why the same data can be shown formatted for people or minified for machines. Formatting changes nothing about the data itself.

Why this formatter keeps your numbers exact

Many online formatters run your text through the browser's JSON.parse and print the result. That quietly changes some data: integers above 9,007,199,254,740,991 (253 - 1) are rounded, so an ID like 12345678901234567890 comes back as 12345678901234567000; numbers such as 1.0 lose their trailing zero; and keys that look like numbers jump to the front of each object. This tool uses its own parser instead, keeps every number and string exactly as you wrote it, and keeps keys in their original order unless you ask it to sort them.

Duplicate keys

RFC 8259 says object names "SHOULD be unique" but does not forbid repeats, and different programs handle them differently (most keep the last value). The formatter keeps duplicates as they are and warns you about the first one so you can decide which value is right.

Limits

Related tools

Need IDs for test data? The UUID generator makes v4 and v7 UUIDs in bulk. Timestamps in an API response? Paste them into the Unix timestamp converter. Writing documentation for an API? The Markdown to HTML converter turns notes into clean HTML, and our GitHub Copilot review looks at AI help for writing the code itself.

Frequently asked questions

How do I format JSON online? +

Paste your JSON into the input box and press Format (or Ctrl+Enter). The formatter checks that it is valid JSON, then re-indents it with 2 spaces, 4 spaces or tabs. If something is wrong, it shows the line and column of the first error instead.

How do I find the error in invalid JSON? +

Press Validate. The tool reports the first problem it finds with its line and column, shows that line with a marker under the exact character, and Go to error selects it in the input. The most common causes are a trailing comma, a missing comma, single quotes and unquoted keys.

Is it safe to paste JSON with private data here? +

This formatter runs entirely in your browser. Your JSON is never uploaded or sent anywhere, and the page has no analytics on what you paste. You can check by disconnecting from the internet after the page loads: everything still works.

What is the difference between formatting and minifying JSON? +

Formatting (pretty printing) adds line breaks and indentation so people can read the structure. Minifying removes all the whitespace that is not inside strings, which makes the file smaller for sending over a network. Both produce exactly the same data.

Does JSON allow comments or trailing commas? +

No. Standard JSON (RFC 8259) has no comments and no trailing commas, and strings and keys must use double quotes. Formats such as JSON5 and JSONC allow them, but a strict JSON parser, including this one, rejects them.

Will sorting keys change my data? +

No. Sorting only changes the order keys appear in objects, which JSON treats as unordered. Arrays keep their order, because order matters in arrays. This tool also keeps numbers exactly as written, so very large integers are not rounded.

Related