Skip to content
ToolPika

JSON Formatter and Validator

Paste JSON to validate and format it instantly. Errors are shown with the exact line and column, and your data never leaves your browser.

Runs in your browser. Nothing you enter is sent to a server.

How it works

The tool reads your JSON character by character with a strict parser that follows the JSON standard (RFC 8259). If it finds a problem, it stops at the first error and shows:

  • the line and column where parsing failed,
  • a plain-English explanation of the rule that was broken,
  • the line itself, with a marker under the exact position.

When the JSON is valid, it is printed again with the indentation you choose (2 spaces, 4 spaces or tabs), or with all whitespace removed (Minify). Sort keys orders the properties of every object alphabetically, which makes two JSON documents easier to compare.

Common errors and how to fix them

Error Invalid Valid
Trailing comma {"a": 1, "b": 2,} {"a": 1, "b": 2}
Single quotes {'name': 'Ana'} {"name": "Ana"}
Unquoted property name {name: "Ana"} {"name": "Ana"}
Missing comma {"a": 1 "b": 2} {"a": 1, "b": 2}
Comment {"a": 1 // note} {"a": 1}
Leading zero {"code": 007} {"code": 7} or {"code": "007"}
Line break inside a string "firstsecond" "first\nsecond"
Not a JSON value {"a": undefined} {"a": null}

Formatting, minifying and file size

Indentation only changes whitespace, never the data. Minified JSON is smaller and faster to send over a network; formatted JSON is easier to read and review. The line under the input shows the size before and after, so you can see how much minifying saves.

Frequently asked questions

Is my JSON sent to a server?

No. Parsing and formatting happen entirely in your browser, so it is safe to paste API responses, configuration files or data containing personal information.

Why does it say my JSON is invalid when it works in JavaScript?

JavaScript object literals are more relaxed than JSON. JSON requires double quotes around every property name and string, and does not allow comments, trailing commas, single quotes, undefined, NaN or Infinity. The error message tells you which rule was broken and where.

Will formatting change my data?

No. Numbers and strings are copied exactly as written. Many online formatters pass the JSON through JavaScript, which rounds large integers such as 12345678901234567890 (common in IDs); this one keeps every digit.

What are duplicate keys and why are they flagged?

The JSON standard says keys should be unique, but does not forbid duplicates. Most parsers silently keep only the last value, which hides bugs. The validator warns you instead of dropping one of them.

What is the largest file I can format?

Up to 2 million characters (about 2 MB). Larger inputs are cut off at that length.