Ad
DevToolXDevToolX

JSON Formatter

Format, validate and beautify JSON data

About JSON Formatter

JSON Formatter parses your input against RFC 8259 and re-serializes it with consistent indentation so every nested key and value becomes readable at a glance. It surfaces syntax errors — trailing commas, single-quoted strings, unquoted keys — that are accepted by many runtime parsers but violate the spec. Useful for inspecting raw API responses, preparing data for diffs, and catching malformed payloads before they reach production.

Common Use Cases

Inspect API responses
Paste a compressed JSON response from curl or a network tab to see the full structure without mentally parsing a single minified line.
Debug malformed JSON
The formatter pinpoints the exact line and column of a syntax error — missing comma, unclosed bracket — so you fix the right spot the first time.
Normalize before diffing
Format two JSON blobs with the same indentation before feeding them into a diff tool; structural differences stand out instead of being obscured by inconsistent whitespace.
Prepare data for embedding in code
Beautify and manually trim a JSON fixture to a clean 2-space indent before copying it into a test file or source constant.

Frequently Asked Questions

Why does my JSON fail here but work in my app?

Many parsers are lenient by design and accept trailing commas, single-quoted strings, or JavaScript comments. RFC 8259 forbids all of these. The formatter validates against the strict standard, which is what any cross-language or cross-platform exchange should follow.

What is JSONC and why doesn't standard JSON allow comments?

JSONC (JSON with Comments) is an unofficial extension used by editors like VS Code for configuration files. Standard JSON intentionally omits comments — Douglas Crockford's rationale was that allowing them would encourage people to embed parsing directives, turning JSON into a configuration format rather than a pure data interchange format. Strip comments before using JSONC files as API payloads.

Is there a size limit?

This tool runs in your browser using JSON.parse. For most inputs up to a few megabytes this is instant. Files above roughly 50–100 MB risk hitting the V8 string limit or causing the tab to stall — for very large files, use a native tool like jq on the command line instead.

How does this differ from JSON.stringify(obj, null, 2) in JavaScript?

JSON.stringify only works on a value already in memory. This tool accepts raw text, validates it before parsing, and reports errors instead of throwing an uncaught exception. Key order is preserved (insertion order), and it handles edge cases like top-level arrays or primitives that stringify handles but some tools do not.

Related Tools