Skip to content

JSON Formatter & Validator

Output

Estimates for educational purposes — not financial, medical, or legal advice. See terms.

JSON (JavaScript Object Notation) is the dominant data format for web APIs, configuration files, and data exchange between services. Keeping it readable is straightforward when you know the right tools.

What this tool does

Format parses your JSON and re-serialises it with consistent indentation. Choose 2 spaces for JavaScript convention, 4 spaces for Python convention, or a tab character for projects that use tab-indented code.

Minify parses your JSON and re-serialises it without any whitespace outside string values. The result is the smallest valid JSON representation of the same data — useful before embedding JSON in a request body or URL parameter.

Validate parses your JSON and reports whether it is syntactically valid. If valid, it summarises the top-level type and size (for example, “object with 5 keys” or “array with 12 items”). If invalid, it reports the error message and the line and column where parsing failed.

Example:

Input (minified):

{"user":{"name":"Alice","roles":["admin","editor"],"active":true}}

Format with 2-space indent:

{
  "user": {
    "name": "Alice",
    "roles": [
      "admin",
      "editor"
    ],
    "active": true
  }
}

Validate result: “Valid JSON — object with 1 key”

Common JSON syntax errors

Trailing comma{"a": 1,} is not valid JSON. Remove the comma after the last value in any object or array.

Single quotes — JSON requires double quotes for all strings and keys. {'a': 1} is JavaScript object literal syntax, not JSON.

Unquoted keys{a: 1} is not valid JSON. Every key must be a quoted string: {"a": 1}.

Comments — JSON has no comment syntax. Remove // ... or /* ... */ before parsing.

JavaScript primitivesundefined, NaN, and Infinity are not valid JSON values. Replace them with null or a numeric equivalent.

Unescaped control characters — literal tab, newline, or carriage return inside a string must be escaped as \t, \n, or \r.

When line and column numbers are approximate

JSON.parse error messages in V8 (Node.js, Chrome) report a character offset from the start of the string. This tool converts that offset to a line and column by counting newlines before it. The result is exact when the error position is reported by V8, but some errors — particularly those on the very first character — may show null for line and column if no position is included in the error message.

Once the JSON parses cleanly, the JSONPath tester lets you pluck out specific values; for round-tripping to YAML or CSV, the YAML ↔ JSON converter and JSON ↔ CSV converter are the adjacent tools.

Frequently asked questions

What is the difference between formatting and validating JSON?

Formatting (also called prettifying or beautifying) assumes your JSON is already valid and re-serialises it with consistent indentation so it is easy to read. Validation checks whether the input can be parsed as JSON at all — if a brace is missing, a key is unquoted, or a trailing comma is present, validation fails and the tool reports the error and the approximate line number where parsing stopped. This tool lets you do both: pick Validate to check syntax first, then pick Format to produce readable output once the JSON is clean.

What is minified JSON and when should I use it?

Minified JSON removes all whitespace (spaces, newlines, indentation) that is not inside a string value, producing the shortest possible valid representation. Minification reduces file size and is used when JSON is sent over a network — for example in API responses or bundled JavaScript data files — where the extra bytes of indentation add up. Human readability is sacrificed entirely. Use minify when you need to paste JSON into a config file, a URL parameter, or a request body where size matters and you will not need to edit it directly.

Why does JSON not allow trailing commas or comments?

JSON was designed as a minimal, unambiguous data interchange format. Douglas Crockford intentionally excluded trailing commas and comments from the spec (ECMA-404, RFC 8259) to keep parsers simple and to avoid ambiguity about whether a comment is data. If you need comments or trailing commas — which are convenient in human-edited config files — consider JSON5 or JSONC (JSON with comments), both of which are supersets of JSON and are supported by editors like VS Code. When exchanging data between systems, stick to standard JSON.

What does line and column mean in a JSON error?

When the parser encounters invalid syntax it stops at the first character it cannot understand. The line and column numbers reported by this tool point to that character in your input. Line 1, column 1 is the very first character of the pasted text. This lets you jump directly to the problem: a missing quote, an extra comma, an unescaped backslash, or a JavaScript-style undefined or NaN value, none of which are valid JSON.