{ } Free Developer Tool · No Signup

JSON Formatter & Validator

Paste your JSON, instantly format, validate, minify, and explore with a collapsible tree view. Runs entirely in your browser — your data never leaves your machine.

✓ 100% client-side ✓ No data sent ✓ Up to 5MB ✓ Free forever
Input  Ctrl+Enter to format
Output
Formatted JSON will appear here...
✓ Valid 0 chars 0 keys Depth: 0 0 B

The Complete Guide to JSON

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format that has become the lingua franca of modern software development. Nearly every API you interact with today — from Twitter to Stripe to your company's internal microservices — sends and receives data as JSON.

The format was popularized by Douglas Crockford in the early 2000s, though it was derived from the object literal syntax already present in JavaScript. Crockford recognized that a minimal, language-independent data format would solve the interoperability problems that XML was struggling with. He formalized the specification, which eventually became RFC 8259 (published by the IETF in 2017), the authoritative standard for JSON.

What makes JSON so successful is its simplicity. The entire specification fits on a single business card. It supports exactly six data types, uses a syntax that is both human-readable and trivially machine-parseable, and maps naturally to data structures in virtually every programming language. Python dicts, JavaScript objects, Java HashMaps, Go structs, Ruby hashes — they all have a direct analogue in JSON.

JSON Syntax Rules

A valid JSON document must be either an object (wrapped in curly braces) or an array (wrapped in square brackets) at the top level. Inside these containers, the rules are strict but straightforward:

Here is a valid JSON document that demonstrates every data type:

{
  "name": "Ada Lovelace",
  "age": 36,
  "isEngineer": true,
  "spouse": null,
  "languages": ["English", "French", "Italian"],
  "address": {
    "city": "London",
    "country": "England"
  }
}

Common Syntax Errors and How to Fix Them

If you have been working with JSON for any length of time, you have encountered the dreaded "Unexpected token" error. Here are the most common causes and how to fix each one.

Trailing commas — this is the single most common JSON error. JavaScript allows trailing commas in objects and arrays, but JSON does not. If your formatter flags an error on the line after the last property, check for a stray comma.

// Invalid: trailing comma
{"name": "Alice", "age": 30,}

// Valid: no trailing comma
{"name": "Alice", "age": 30}

Single quotes — JSON requires double quotes for all strings and keys. This trips up Python developers (where single and double quotes are interchangeable) and JavaScript developers accustomed to using single quotes by convention.

// Invalid: single quotes
{'name': 'Alice'}

// Valid: double quotes
{"name": "Alice"}

Unquoted keys — in JavaScript, {name: "Alice"} is perfectly valid. In JSON, it is a syntax error. Every key must be a double-quoted string.

Comments — JSON does not support comments. Not //, not /* */, not #. This was a deliberate design decision by Douglas Crockford to prevent comments from being used as parsing directives (a problem that plagued XML). If you need comments in config files, consider JSON5 or JSONC (the format VS Code uses for settings.json).

Special JavaScript valuesundefined, NaN, Infinity, and functions are valid JavaScript values but are not part of the JSON specification. If you use JSON.stringify() on an object containing undefined, those keys are silently dropped. NaN and Infinity will throw an error.

How to Format JSON

Minified JSON — a single line of densely packed text with no whitespace — is great for transmission but terrible for reading. Formatting (also called "pretty-printing" or "beautifying") adds line breaks and indentation so you can actually see the structure.

Consider this minified response from an API:

{"users":[{"id":1,"name":"Alice","roles":["admin","editor"]},{"id":2,"name":"Bob","roles":["viewer"]}]}

After formatting with 2-space indentation, the same data becomes immediately legible:

{
  "users": [
    {
      "id": 1,
      "name": "Alice",
      "roles": [
        "admin",
        "editor"
      ]
    },
    {
      "id": 2,
      "name": "Bob",
      "roles": [
        "viewer"
      ]
    }
  ]
}

The data is identical. But the formatted version lets you instantly see that there are two users, Alice has two roles, and Bob has one. When you are debugging a 500-line API response at 2 AM, this difference matters enormously.

The tool above lets you switch between 2-space, 4-space, and tab indentation depending on your team's convention. There is no "right" answer — 2 spaces is the most common in JavaScript/TypeScript projects, 4 spaces is popular in Python and Java ecosystems, and tabs are the accessibility-friendly option (users can configure their display width).

JSON in API Development

JSON dominates API development. The vast majority of REST APIs use JSON as their request and response format, and GraphQL exclusively returns JSON. Understanding how to read, format, and validate JSON is a foundational skill for anyone working with APIs.

When debugging API responses, your first step should always be to paste the raw response into a formatter. Minified JSON from curl or browser DevTools is nearly impossible to read without formatting. A quick curl -s https://api.example.com/users | python -m json.tool on the command line, or pasting into a tool like this one, saves minutes of squinting at dense text.

For programmatic use, the fetch() API in JavaScript makes JSON handling seamless: response.json() parses the response body into a native JavaScript object. In Python, the requests library offers response.json() for the same purpose. And command-line tools like jq let you slice, filter, and transform JSON directly in your terminal — making it indispensable for shell scripting and pipeline debugging.

Why JSON won over XML: JSON's rise came at the expense of XML, which had dominated data interchange throughout the late 1990s and early 2000s. JSON won because it is dramatically simpler (no closing tags, no attributes vs. elements distinction, no DTDs or namespaces), maps more naturally to programming data structures, and produces significantly smaller payloads. A JSON representation of the same data is typically 30-50% smaller than its XML equivalent.

JSON Schema Validation

Syntax validation (which this tool provides) tells you whether a JSON document is well-formed. But in production systems, you often need schema validation — verifying that the JSON conforms to an expected structure. Does the email field exist? Is age a positive integer? Are all required fields present?

JSON Schema is a vocabulary that lets you define the structure, constraints, and documentation of your JSON data. It is itself written in JSON, and it has become the industry standard for API contract validation, form generation, and documentation. Major tools like Swagger/OpenAPI, Postman, and Ajv all use JSON Schema under the hood.

A basic JSON Schema for a user object might look like this:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "required": ["name", "email"],
  "properties": {
    "name": { "type": "string", "minLength": 1 },
    "email": { "type": "string", "format": "email" },
    "age": { "type": "integer", "minimum": 0 }
  }
}

This schema guarantees that any conforming document has a non-empty name string and a valid email, with an optional non-negative age. Schema validation catches entire classes of bugs that syntax validation alone cannot — missing fields, wrong types, out-of-range values — before they reach your application logic.

Tips for Working with JSON

Frequently Asked Questions

Is this JSON formatter free?+
Yes, 100% free with no signup, no email required, and no paywall. Everything runs in your browser using JavaScript. We built it as a free tool for the developer community. There are no premium tiers, no feature gates, and no usage limits.
Is my data safe?+
Yes. Everything runs entirely in your browser. Your JSON data is never sent to any server, never logged, and never stored. You can verify this by opening your browser's Network tab — you will see zero outbound requests when using the tool. It even works offline after the first page load.
What is the maximum JSON size I can format?+
This tool handles JSON up to approximately 5MB. For very large files, formatting uses optimized rendering techniques to avoid freezing your browser. If you regularly work with files larger than 5MB, consider using a desktop tool like VS Code or command-line jq.
What is the difference between JSON and JavaScript objects?+
JSON (JavaScript Object Notation) is a strict text-based data format. JavaScript objects are in-memory data structures. Key differences: JSON requires double quotes around all keys and string values, does not support comments, trailing commas, undefined, functions, or single quotes. A JavaScript object like {name: 'Alice', age: 30} is valid JS but invalid JSON. The JSON equivalent is {"name": "Alice", "age": 30}.
Can JSON have comments?+
No. The official JSON specification (RFC 8259) does not allow comments. Douglas Crockford intentionally excluded them to keep the format simple and interoperable. However, variants like JSON5 and JSONC (used by VS Code for settings.json) do support both single-line and multi-line comments. If you need comments in configuration files, consider using JSON5, YAML, or TOML instead.

Built for Developers, by Developers

Check out our other free developer tools, or browse thousands of open engineering roles at top AI and tech companies.

All Developer Tools → Browse 14,600+ AI & Tech Jobs →