JSON Formatter & Validator

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format. Despite its name, JSON is language-independent and supported by virtually every modern programming language. It was formalized by Douglas Crockford in the early 2000s and standardized as RFC 8259.

JSON represents data using two universal structures: objects (unordered collections of key-value pairs, enclosed in curly braces) and arrays (ordered lists of values, enclosed in square brackets). Values can be strings, numbers, booleans (true/false), null, objects, or arrays. This simplicity is what makes JSON the dominant format for APIs, configuration files, and data storage.

JSON Syntax Rules

JSON is strict about syntax. The most common rules to remember:

  1. Keys must be double-quoted strings. {"name": "Alice"} is valid; {name: "Alice"} is not.
  2. Strings use double quotes only. Single quotes ('hello') are invalid in JSON.
  3. No trailing commas. {"a": 1, "b": 2,} will fail to parse.
  4. No comments. JSON does not support // or /* */ style comments.
  5. No undefined, NaN, or Infinity. These JavaScript values have no JSON equivalent.

How to Use This Formatter

  1. Paste or type your JSON into the input panel on the left.
  2. Click Format to pretty-print it with 2-space indentation, or Minify to compress it into a single line.
  3. If the JSON is invalid, an error message will appear showing exactly what went wrong.
  4. Use Tree view to explore the structure interactively — click nodes to collapse and expand them.
  5. Click Copy output to copy the result to your clipboard.

Everything runs in your browser. No data is sent to any server.

JSON vs. XML vs. YAML

JSON is the most widely used format for web APIs because it is compact, fast to parse, and maps naturally to data structures in most languages. XML is more verbose but supports attributes, namespaces, and schemas natively, making it common in enterprise systems and document-oriented formats like SVG and XHTML. YAML is a superset of JSON with a more human-friendly syntax — it supports comments, multi-line strings, and anchors — and is popular for configuration files (Docker Compose, Kubernetes, CI/CD pipelines). For data exchange between services, JSON is the default choice. For human-edited config files, YAML often wins.

Common JSON Errors

When your JSON fails to parse, it is almost always one of these issues:

The formatter above highlights the exact error location so you can fix it quickly.

Frequently Asked Questions

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format. It is language-independent and easy for both humans to read and machines to parse. JSON represents data as key-value pairs (objects) and ordered lists (arrays), using a syntax derived from JavaScript object literals. It is the standard format for web APIs and configuration files.

How do I validate JSON?

Paste your JSON into the input field above and click Format. If the JSON is valid, it will be pretty-printed in the output panel. If it contains errors, you'll see a specific error message indicating what went wrong. Common issues include missing commas, trailing commas, unquoted keys, and single quotes instead of double quotes.

Can JSON have comments?

No. The JSON specification (RFC 8259) does not allow comments. If you need comments in a configuration file, consider JSON5, JSONC (used by VS Code), YAML, or TOML. Pasting JSON with comments into a strict parser will produce a syntax error.

What's the difference between JSON and JavaScript objects?

JSON is a strict subset of JavaScript object literal syntax. JSON requires double-quoted keys, does not allow functions or undefined as values, forbids trailing commas, and does not accept single quotes. {name: 'Alice'} is valid JavaScript but invalid JSON. The correct JSON form is {"name": "Alice"}.

What is JSON Schema?

JSON Schema is a vocabulary for describing the structure and constraints of JSON documents. It defines expected types, required fields, string patterns, numeric ranges, and more. It is widely used for API validation, form generation, and configuration file validation.

Why is my JSON invalid?

The most common causes are: trailing commas after the last element, single quotes instead of double quotes, unquoted property names, missing commas between elements, and JavaScript-specific values like undefined, NaN, or Infinity. Use the formatter above to see the exact error location.

What's the maximum size of a JSON file?

The JSON specification defines no maximum size. Practical limits depend on the parser and available memory. Most web APIs accept payloads up to 1-10 MB. JavaScript's JSON.parse() can handle strings of hundreds of megabytes in modern browsers. For very large datasets, consider streaming parsers or newline-delimited JSON (NDJSON).