What is a JSON formatter?
A JSON formatter, or beautifier, takes JSON that's hard to read, usually because it's been minified onto one line, and adds indentation and line breaks so its structure is clear. A validator checks that it follows JSON's strict syntax and shows where it doesn't.
Developers use this constantly: reading API responses, checking a configuration file before deploying, cleaning up a log entry, or making a payload readable for a bug report. This one also minifies, sorts keys alphabetically, and reports the number of keys, the nesting depth and the size in bytes.
How to use the JSON Formatter
1.Paste JSON
An API response, a config file or a log line; minified or messy is fine.
2.Choose a format
Two or four spaces, tabs, or minified, and optionally sort keys alphabetically.
3.Fix or copy
Errors point to the line and column; valid JSON can be copied or downloaded.
Example: a minified config
The sample one-line JSON on this page, formatted with 2-space indentation:
- Valid
- yes
- Keys
- 8
- Nesting depth
- 3
- Lines after formatting
- 16
Adding a trailing comma after "csv" makes it invalid, and the error points to that line and column.
Validation that tells you where
The JSON is parsed with the browser's own strict JSON parser, so anything it accepts is valid JSON by the standard (RFC 8259). When it fails, the error is translated into a line and column, which beats hunting for a stray comma in a single 2,000-character line.
Common mistakes are trailing commas, single quotes instead of double quotes, unquoted keys and comments, all allowed in JavaScript but not in JSON. Sorting keys makes two JSON documents easy to compare in a diff tool.
Frequently asked questions
Why is my JSON invalid?
Usually a trailing comma, single quotes, an unquoted key or a comment. The error message points to where the parser stopped.
Is my JSON sent to a server?
No. Formatting and validation happen in your browser, so it's safe for internal data, but avoid pasting secrets anywhere out of habit.
What's the difference between formatting and minifying?
Formatting adds indentation and line breaks for people; minifying removes them to make the file smaller for machines.
How big a file can it handle?
Several megabytes comfortably; very large files depend on your device's memory.
Related tools
JSON ↔ CSV Converter
Convert JSON arrays to CSV and CSV back to JSON.
JSON to TypeScript Interface Generator
Generate TypeScript interfaces or types from a JSON sample.
JSON ↔ YAML Converter
Convert JSON to YAML and YAML to JSON.
JWT Decoder
Decode a JSON Web Token's header and payload and check its expiry.
Base64 Encoder & Decoder
Base64 and Base64url for text (UTF-8) and files.
URL Encoder & Decoder
Percent-encode or decode URLs and query values, and see a URL's parts.