JSON Formatter

Paste JSON to auto-format, validate, and spot errors with inline highlighting.

runs locally on your browser. Your data never leaves your device.

Common Use Cases

Pretty-print a minified API response to inspect its structure during debugging
Validate a JSON config file before deploying it to a server
Minify a large JSON payload before sending it in a network request
Check for syntax errors in a hand-written JSON document

About JSON Formatter

JSON (JavaScript Object Notation) is the lingua franca of modern APIs and data exchange. It's lightweight, human-readable, and natively supported in virtually every programming language. But working with raw JSON, especially minified API responses, single-line log payloads, or deeply nested configurations, is painful without a formatter.

This tool does three things at once: it validates your JSON (instantly shows you if there's a syntax error and where it is), formats it with consistent 2-space indentation, and highlights the structure so objects, arrays, strings, and numbers are visually distinct. It also handles the most common JSON pitfalls: trailing commas (valid in JavaScript objects but not in JSON), single quotes (JSON requires double quotes), and unquoted keys.

Beyond basic formatting, a well-structured view reveals structural problems that are hard to spot in minified JSON: missing closing brackets, mismatched nesting, accidentally stringified numbers (like `"count": "42"` instead of `"count": 42`), and null vs undefined issues.

The minify mode reverses the process: it strips all whitespace and produces the most compact representation, which reduces payload size when sending data over a network. A typical API response formatted for readability might be 15-20KB; the same data minified might be 5-6KB.

Both formatting and minification run locally in your browser. Paste a 10MB JSON file and it processes in under a second without uploading anything.

Frequently Asked Questions

What JSON syntax errors does this tool detect?
The tool validates against the full JSON specification (RFC 8259). It detects: trailing commas after the last element in an object or array, single-quoted strings (JSON requires double quotes), unquoted object keys, missing commas between elements, mismatched or missing brackets and braces, and invalid escape sequences in strings.
What is the difference between formatting and minifying JSON?
Formatting (or 'pretty-printing') adds newlines and indentation to make the structure human-readable. Minifying removes all unnecessary whitespace to reduce file size. Use formatted JSON in configuration files and during development; use minified JSON in production API responses where payload size matters.
Can I format JSON with comments?
Standard JSON does not support comments. If your JSON contains // or /* */ comments, it's technically not valid JSON; it might be JSONC (JSON with Comments) or JSON5. This tool will report a syntax error. Strip comments before formatting, or use a JSONC-aware editor like VS Code.
Does this tool handle very large JSON files?
Yes, it runs entirely in your browser, so there is no upload size limit imposed by a server. Practical limits depend on your device's memory and the browser's JavaScript engine. Most modern devices handle files up to 50MB without noticeable lag.
Why does my JSON formatter show an error for a valid-looking key?
JSON object keys must be double-quoted strings. A key like myKey: 'value' or myKey: "value" (with an unquoted key) is invalid JSON even if it's valid JavaScript object literal syntax. Ensure every key is wrapped in double quotes: "myKey": "value".