Free JSON Formatter & Validator Online

Paste your JSON to format, minify, or validate it instantly. All processing happens in your browser.

Your data never leaves your device
$

What JSON Is and Why It Took Over the Web

JSON (JavaScript Object Notation) is a text-based data interchange format derived from JavaScript object literal syntax. It supports six data types (objects, arrays, strings, numbers, booleans, and null) and nothing else. Douglas Crockford specified the format in 2001 as a deliberately minimal alternative to XML, publishing the design at json.org with the explicit goal of making "the fat-free alternative to XML." The IETF standardised JSON as RFC 4627 in July 2006, refined it as RFC 7159 in March 2014, and again as RFC 8259 in December 2017 (current STD 90, the active standard, also published in parallel as ECMA-404). JSON's takeover of the web's data plane happened roughly between 2008 and 2014: as single-page apps and mobile clients grew, the verbose XML payloads that earlier APIs used were replaced by JSON. By 2026 essentially every public REST API documents itself in JSON; XML survives in document formats and enterprise integration but JSON owns the API economy. This tool reads JSON, validates it against the spec, and re-emits it formatted (indented, line-broken) or minified (whitespace stripped).

What "Format JSON" Actually Does

JSON is whitespace-insensitive at the spec level, a parser reads {"name":"Alice","age":30} identically to the multi-line indented form. The visible difference is purely for human readers. Formatting (also called "pretty-printing" or "beautifying") inserts indentation between nested levels, places each property on its own line, and adds blank space after the colon between key and value. Minifying does the inverse: strip every byte of whitespace except inside string literals. Production HTTP responses are typically minified to save bandwidth (gzip and Brotli at the CDN edge handle the rest); during development the formatted version is what you read. The standard formatting conventions: 2 spaces per indent level (the modern web default, Prettier's default, the JavaScript ecosystem norm), 4 spaces for codebases that follow Python-influenced conventions, or 1 tab for projects that prefer tab indentation. JSON.stringify() in JavaScript takes an integer or string second argument controlling exactly this, JSON.stringify(data, null, 2) produces 2-space indented output. This tool exposes the same three options.

JSON Is Strict, The Rules That Trip People Up

JSON's grammar is famously unforgiving. Object keys must be quoted with double quotes (single quotes are not legal). String values must use double quotes. No trailing commas after the last property of an object or last element of an array, a frequent source of JavaScript-developer surprise because JS itself accepts trailing commas. No comments: unlike YAML or JavaScript, JSON has no comment syntax. No undefined value: JSON has only null; trying to JSON-encode JavaScript's undefined drops the property entirely. Numbers must be in JSON-decimal form: no leading zeros (007 illegal), no hex (0x7F illegal), no Infinity or NaN. Strings must be valid UTF-8: most parsers tolerate UTF-16 surrogate-pair issues but the spec requires well-formed Unicode. Duplicate keys are technically valid per the spec but produce undefined behaviour in most parsers (last value usually wins). Several JSON variants relax these rules: JSON5 (Aseem Kishore, 2012) allows trailing commas, single quotes, comments, and other ergonomic relaxations; JSONC (used by VS Code's tsconfig.json and similar) is JSON with C-style line comments allowed; HJSON aims at human-friendliness with quoted keys optional. None are JSON proper, they need their own parsers, and most production tooling expects strict JSON per RFC 8259.

Where Formatted JSON Earns Its Keep

JSON in the Wider Tooling Ecosystem

For command-line workflows, jq (Stephen Dolan, first released 2012) is the canonical JSON processor, a small, statically-linked binary that handles formatting (jq .), filtering (jq '.users[] | .email'), transformation, and complex queries with its own concise expression language. Python's standard library includes python -m json.tool for one-shot pretty-printing. JavaScript's built-in JSON.stringify(obj, null, 2) is the fastest in-browser/in-Node formatter. JSON Schema (current draft 2020-12, edited by Henry Andrews, Austin Wright, Greg Dennis and others) provides a vocabulary for declaring what shape a JSON document must have (type constraints, required properties, format validators, conditional logic) and is the standard for API contract validation, OpenAPI 3.x specifications, configuration validation, and JSON-based form generation. JSONPath (Stefan Goessner, 2007, now standardised as RFC 9535 in February 2024) is the XPath-like query language for JSON, used by jq's simpler subset and by tools like Postman, jsonpath-ng (Python), and the AWS CLI. JSON-LD (W3C Recommendation, current version 1.1 published July 2020) extends JSON with semantic-web linked-data conventions and is the format Google recommends for structured-data markup on web pages. JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7396) define standardised diff/patch formats for JSON documents.

Tree View, Why It Matters

A pretty-printed JSON document of even moderate size (a few hundred lines) is hard to navigate as flat text. The tree view in this tool collapses each object and array into an expandable node, lets you click in to see only the levels you care about, and shows the JSONPath expression for any node you click. The path-on-click feature is the practical bridge between "I can see the value I want in the document" and "I can write code that accesses that value", paste the path into jq, into a JSONPath query, into JavaScript bracket notation, into a Postman test assertion. For deeply nested API responses (Stripe, Shopify, Salesforce, anything with rich domain models), tree view + path-copy is the workflow that takes "I see the field" to "I have the access expression" in two clicks.

Privacy: Browser-Only Validation

JSON pasted into a formatter is frequently real production data, API responses with user identifiers, session tokens, internal entity IDs, configuration values that include endpoint URLs and feature flags. Server-side JSON formatters take a copy of every input into their logs. This tool parses your JSON with the browser's built-in JSON.parse(), walks the resulting structure in JavaScript, and re-emits it as a string, all inside your browser tab. Verify in DevTools' Network tab while you click Format (no requests fire), or take the page offline (airplane mode) after it loads and the formatter still works. Safe for production API responses, internal config, JSON containing tokens or keys, or any document you wouldn't want copied onto a stranger's hard drive.

Frequently Asked Questions

Why does my JSON fail validation?

The most common errors: trailing commas after the last property/element (legal in JavaScript and JSON5, illegal in standard JSON); single quotes instead of double quotes (JSON requires " only); unquoted keys (JavaScript object literals allow {name: "Alice"} but JSON requires {"name": "Alice"}); comments (JSON has no comment syntax, use JSON5 or JSONC if you need them); undefined values (JSON has only null); missing brackets/braces; special floats like NaN or Infinity (illegal in JSON). The validator's error message gives the line and column; check there first.

What's the difference between format and minify?

Format adds indentation, line breaks and spacing to make the JSON readable; minify removes all unnecessary whitespace to make it as small as possible. The actual data content is identical, JSON parsers ignore whitespace at the syntax level. Use formatted for development, debugging and code review; use minified for HTTP transmission, embedded JSON in JavaScript bundles, or any context where bytes matter. Modern infrastructure (gzip on HTTP responses, Brotli at the CDN edge) compresses JSON aggressively so the bandwidth difference is smaller than it looks, but minified is still slightly smaller and faster to parse.

Is there a size limit?

No hard cap, but practical limits depend on browser memory. Files up to ~10 MB format and validate in well under a second on modern devices; files in the 50-100 MB range may briefly freeze the tab while JSON.parse() walks the structure. For very large JSON (gigabytes, typical for large API exports or NDJSON log dumps), command-line tools (jq, python -m json.tool, node -e) handle them better because they can stream rather than loading everything into memory.

What does "Sort Keys" do and when should I use it?

Sort Keys alphabetises every object's keys recursively. The data semantics are unchanged (JSON object key order is technically undefined per the spec, though most parsers preserve insertion order) but the output becomes canonical. Useful for diffing two JSON documents that should be semantically equivalent (without sorting, key-order differences produce noisy diffs), and for producing reproducible build outputs (the same data should always serialise to byte-identical JSON regardless of how it was constructed in memory).

Are my JSON documents uploaded?

No. All parsing, validation, formatting, sorting and tree rendering happens in your browser via JSON.parse() and JavaScript. The pasted JSON never crosses the network. Verify in DevTools' Network tab while you click Format (no requests fire), or take the page offline (airplane mode) after it loads. Safe for proprietary API responses, internal configuration, JSON containing tokens or session data, or anything covered by NDA.

Related Tools