MSMuhammad Shahid

Free tool · runs in your browser

JSON formatter and validator

Paste JSON to format it with readable indentation, minify it to one line, or find exactly where it is broken.

Quick answer

Paste your JSON and choose Format for readable, indented output or Minify to remove all whitespace. If the JSON is invalid, the tool shows the error message from the browser's own JSON parser, which points at the problem, such as a trailing comma or a missing quote.

How to use it

  1. Paste your JSON. From an API response, a config file or a log.
  2. Format or minify. Format adds indentation (2 spaces, 4 spaces or tabs); minify puts it on one line.
  3. Fix any errors. If it is invalid, read the error, fix that spot and try again.

Example

Minified JSON from an API response, formatted with 2-space indentation:

Input

{"id":42,"name":"Sara Levi","roles":["admin","editor"],"active":true}

Output

{
  "id": 42,
  "name": "Sara Levi",
  "roles": [
    "admin",
    "editor"
  ],
  "active": true
}

Common errors and how to fix them

Expected double-quoted property name in JSON at position …
Usually a trailing comma after the last item, as in {"a": 1,}. Remove the comma before the closing } or ].
Expected property name or '}' in JSON at position 1
The keys are not in double quotes: {a: 1} or {'a': 1}. JSON needs "a" with double quotes, for keys and for strings.
Unexpected token '<', "<!DOCTYPE "… is not valid JSON
You received an HTML page instead of JSON, often an error page, a login page or a wrong URL. Check the status code and the response before calling JSON.parse.
Unexpected end of JSON input
The text is empty or cut off: a missing closing bracket, or an empty response body. Check that the whole response arrived.

Frequently asked questions

What are the most common JSON errors?

Trailing commas after the last item, single quotes instead of double quotes, unquoted keys, and comments, which JSON does not allow.

Is my JSON sent to a server?

No. Formatting and validation run in your browser.

What is the difference between formatting and minifying?

Formatting adds line breaks and indentation for people to read; minifying removes them to make the data as small as possible for sending.

Can JSON have comments?

No. Standard JSON does not allow comments; remove them or use a format such as JSONC that your tool supports.

How large a JSON file can I format?

Several megabytes work fine in a modern browser; very large files may be slow because everything runs on your device.

What is the difference between JSON and a JavaScript object?

JSON is a text format with stricter rules: keys and strings in double quotes, no trailing commas, no comments, and no functions or undefined values.

How do I format JSON in JavaScript?

JSON.stringify(value, null, 2) formats with two-space indentation, and JSON.parse(text) reads JSON into an object.

Why does my JSON have escaped quotes like \"?

It was probably encoded twice: a JSON string inside JSON. Parse it once more to get the object.

Can JSON contain dates?

Not as a type. Dates are usually stored as ISO 8601 strings, such as "2026-10-31T12:00:00Z", or as Unix timestamps.

What is JSON Lines?

A format with one JSON object per line, common for logs and data exports. Format each line separately.

Sources

Related

More tools in this group

Guides and apps