Developer Tools
JSON Formatter & Validator - Pretty Print, Minify, Validate
Format, validate, and minify JSON instantly in your browser. Pretty-print with 2-space, 4-space, or tab indentation. Sort keys alphabetically. Parse errors shown with line and column. Nothing leaves your computer.
Paste JSON above to format, validate, or explore it.
What does a JSON formatter do?
A JSON formatter takes raw, often compressed or inconsistently indented JSON text and re-serializes it with consistent indentation. The result is easier to read, diff, and debug. This formatter supports 2-space and 4-space indentation (the two most common styles in JavaScript projects), tab indentation (common in Go and other languages), and minification (useful for shrinking payloads for HTTP requests or storage).
JSON validation and error location
Validation is performed by the browser's native JSON.parse: the same parser your
JavaScript runtime uses. When the input is invalid, the parser throws a
SyntaxError containing a character position (in V8/Chrome/Node) or a line and column
number (in Firefox/SpiderMonkey). This formatter extracts that information and displays it as a
human-readable "Line X, column Y" message, making it much faster to locate the offending character
in large JSON documents.
Key sorting
Enabling Sort keys reorders every object's properties alphabetically at every level of nesting. This is useful for producing deterministic JSON output, for example when comparing two API responses that contain the same data in different key orders, or when diffing configuration files. Sorting is applied before formatting, so the output is fully deterministic regardless of the original key order.
Tree view
The Tree view tab renders the parsed JSON as a collapsible tree. Each object and array can be expanded or collapsed independently. Objects show their key count and arrays show their element count in the collapsed state. This is useful for navigating deeply nested JSON without manually searching through text.
JSON5 and JSONC
Standard JSON has strict rules: no comments, no trailing commas, no single-quoted strings, no unquoted keys. Two popular supersets relax these rules:
- JSON5: supports comments, trailing commas, single-quoted strings, unquoted keys, and hex literals. Used in some configuration tools.
- JSONC (JSON with Comments): JSON plus C-style
//and/* */comments. Used by VS Code, TypeScript (tsconfig.json), and other tooling.
This formatter validates and formats strict JSON (RFC 8259). JSONC and JSON5 files must be converted to standard JSON first (strip comments, remove trailing commas).
Large JSON performance
This tool handles most JSON files well. For very large files (>5 MB), browser-based tools become slow due to rendering limits. For large JSON, consider command-line tools:
-
jq . input.json- format and query JSON with the ubiquitousjqtool python3 -m json.tool input.json- format using Python's standard librarycat input.json | fx- interactive JSON explorer in the terminal