JSON Formatter
Professional JSON formatter with tree view, diff compare, schema validation, and syntax highlighting.
JSON Formatter
Format, validate, and analyze JSON with advanced tools
Format Options
Paste JSON above and click "Format" to see the output here
Free JSON Formatter and Validator Online
A JSON formatter takes raw, minified, or malformed JSON and restructures it into clean, properly indented, human-readable output. JSON (JavaScript Object Notation) is the universal data format for REST APIs, configuration files, and web applications, but API responses and log files are almost always minified and unreadable without a formatter.
This free online JSON formatter goes beyond pretty-printing: it validates syntax, shows a collapsible tree view, compares two JSON documents, and supports JSONC (JSON with comments).
How to format JSON online
- Paste your raw or minified JSON into the input panel.
- Click Format to beautify and validate instantly.
- Use the tree view to collapse and expand nested objects and arrays.
- Switch to the Diff tab to compare two JSON documents side by side.
- Copy the formatted output or download it as a file.
JSON validation: common errors explained
- Trailing comma:
{"key": "value",}is invalid in JSON (valid in JSONC). The formatter highlights the exact line. - Single quotes: JSON requires double quotes for strings. Single quotes cause a parse error.
- Unquoted keys: Unlike JavaScript objects, JSON keys must always be quoted strings.
- Comments: Standard JSON does not support comments. Use the JSONC mode to handle
// lineand/* block */comments.
Beautify vs Minify JSON
- Beautify: Adds indentation and line breaks for readability. Use during development, debugging, and code review.
- Minify: Removes all whitespace and optional formatting to reduce payload size. Use for API responses, localStorage data, and production configs.
JSON diff and schema validation
The built-in diff tool highlights added, removed, and changed keys between two JSON documents: useful for comparing API response versions, config snapshots, or migration output. The JSON Schema validator checks that your data matches a defined structure and reports missing required fields, wrong types, and enum violations.
Most of the JSON you paste here comes from a public API. The CodeHelper API directory lists 600 plus of them with authentication, HTTPS and CORS details, including finance and geocoding APIs.
Frequently Asked Questions
How do I fix the error Unexpected token in JSON?
The formatter reports the line and column of the first invalid character. The usual culprits are a trailing comma before a closing bracket, single quotes instead of double quotes, an unquoted key, or a comment. Turn on Accept comments and Strip trailing commas to have the tool clean up JSONC style input automatically.
What is the difference between JSON and JSONC?
JSONC is JSON with comments, used by VS Code settings, tsconfig.json and many config files. Standard JSON.parse rejects // and /* */ comments and trailing commas. With the JSONC option on, the formatter strips them before parsing and outputs strict JSON that any parser accepts.
How does the JSON diff work?
Open the Diff tab, paste the original document as JSON A and the new one as JSON B, then click Compare. The result is split into added keys, deleted keys and modified values, each shown as a small tree with the path to the change. Both documents are parsed first, so formatting and key order do not count as differences.
Can I validate JSON against a JSON Schema?
Yes. Open the JSON Schema Validation panel, paste a draft 7 or 2019-09 schema, and click Validate. The validator lists every violation with its path, the failing keyword and the expected value, for example a missing required field, a wrong type or a value outside an enum.
Is my JSON uploaded anywhere?
No. Parsing, formatting, diffing and validation run in your browser with JavaScript. Nothing is sent to a server, so API responses and configuration files with secrets can be formatted safely.
Related
Free forever, no ads, no tracking. Support the project