RevealTheme logo

JSON Formatter & Validator

Format, beautify, validate, and minify JSON. Runs entirely in your browser — your data never leaves your device.

How to use this tool

  1. 1

    Paste your JSON into the input field.

  2. 2

    Click Format to pretty-print with indentation, or Minify to remove whitespace.

  3. 3

    Errors point to the exact line and column where parsing failed.

  4. 4

    Copy the result to your clipboard.

What is JSON and why does formatting matter?

JSON (JavaScript Object Notation) is the lingua franca of modern web APIs, configuration files, and structured logging. Every REST and GraphQL API returns JSON; every package.json, tsconfig.json, and most CI configs are JSON; AWS, GCP, and Azure speak JSON in their CLIs. JSON's strength is its minimal grammar — six structural characters ({}, [], comma, colon, quote), four primitive types (string, number, boolean, null), and recursive nesting. That minimalism is also its drawback: JSON has no comments, no trailing commas, no unquoted keys, and no multi-line strings. A single misplaced quote or comma breaks the entire document. This tool validates input against RFC 8259 (the JSON specification), then either pretty-prints it with consistent indentation for human reading, or strips all whitespace for network transmission. Parsing and formatting both run entirely in your browser using the JavaScript engine's native JSON.parse and JSON.stringify — the same code that runs in Node.js servers and every browser. That means your data never crosses the network, and the validation behavior here exactly matches what your production code will see.

Common use cases

  • Debug API responses by pasting them into the formatter — instantly see the structure that minified JSON hides.

  • Validate JSON before submitting it to a strict consumer (AWS CloudFormation, Kubernetes manifests, etc.).

  • Pretty-print logs from structured logging libraries (Pino, Bunyan) that emit single-line JSON.

  • Minify config files before embedding them in HTML or environment variables (smaller, fewer bytes parsed).

  • Format JSON Web Token payloads after decoding them from base64.

  • Compare two API responses by formatting both and diffing them.

Frequently asked questions

Does my JSON leave the browser?
No. All parsing and formatting happens in your browser using the built-in JSON.parse and JSON.stringify functions. The data never touches a server, never appears in logs. Safe to use with API responses containing tokens, customer data, or other secrets.
Can I format JSON5 or JSONC (with comments)?
No — this tool follows the strict JSON spec (RFC 8259). Comments and trailing commas are syntax errors and will produce a parser error message. For relaxed JSON variants, use a JSON5 parser like json5.org, or run your input through a preprocessor that strips comments first.
What indent size should I use?
2 spaces is the JavaScript/web convention and the most universal. 4 spaces is the Python ecosystem default (matches PEP 8 indentation). Tabs render inconsistently across editors and break diff tools — avoid tabs unless your team has a strict tab convention. The choice is purely cosmetic; parsers don't care.
Why does minified JSON matter?
Minified JSON saves bytes — meaningful at scale (e.g., a public API returning 100KB of data to millions of requests). For small config files (under a few KB), the difference is negligible. Browser parse times are identical for formatted and minified JSON, so the only reason to minify is bandwidth.
How do I read the error messages?
JavaScript's JSON.parse error messages include the position (offset from start) where parsing failed. Common errors: 'Unexpected token' usually means a missing quote, missing comma, or unescaped special character. 'Unexpected end of JSON input' means the document is truncated. 'Unexpected non-whitespace character' often means a trailing comma.
Can I format very large JSON files?
Browser JSON.parse handles files up to roughly 100MB before performance becomes painful. For files larger than that, use jq on the command line — it can stream-process arbitrarily large JSON.
What's the difference between JSON and JavaScript object literals?
JSON is a strict subset of JavaScript object literal syntax. Differences: JSON keys must be double-quoted strings (JS allows unquoted keys and single quotes); JSON forbids comments, trailing commas, and undefined; JSON has no expressions, function calls, or computed values. JavaScript can eval JSON safely; JSON cannot eval arbitrary JavaScript.

Related tools