JSON formatter & validator

Format, minify, and validate JSON instantly. See syntax errors with line numbers — everything runs in your browser.

Paste or type JSON above

What is JSON?

JSON (JavaScript Object Notation) is a lightweight data interchange format. Originally derived from JavaScript, it has become the universal standard for data exchange between web services, APIs, and applications. JSON's simplicity — built from just objects, arrays, strings, numbers, booleans, and null — makes it both human-readable and machine-parseable.

Most modern APIs return JSON by default, and configuration files across every major platform (package.json, tsconfig.json, composer.json) use it as their format of choice. Understanding how to read, write, and validate JSON is a fundamental skill for any developer.

Common JSON errors and how to fix them

Trailing commas are the number one cause of invalid JSON. JavaScript allows a comma after the last item in an array or object ([1, 2, 3,]), but JSON does not. Remove the final comma before any closing bracket or brace.

Single quotes instead of double quotes are another frequent mistake. JSON requires double quotes for both property names and string values. {'name': 'value'} is valid JavaScript but invalid JSON — it must be {"name": "value"}.

Unquoted property names trip up developers coming from JavaScript, where { name: "value" } is perfectly valid. In JSON, every key must be a double-quoted string.

Comments are not allowed in standard JSON. If you paste code from a JSONC file (like VS Code's settings.json), strip the comments first. For files that need comments, consider JSON5 or YAML.

Missing commas between properties often happen when copying and pasting. Each key-value pair (except the last) must end with a comma. The error message will typically point to the line after the missing comma.

Invalid values like undefined, NaN, Infinity, and function references are valid in JavaScript but not in JSON. Replace them with null, a number, or remove them entirely.

JSON formatting best practices

Indentation is a matter of convention, but 2-space indentation is the most common choice in the JavaScript ecosystem. Node.js, npm, and most linters default to 2 spaces. Some teams prefer 4 spaces (common in Python ecosystems) or tabs. The important thing is consistency — pick one and enforce it with a formatter.

Minify for production. If you're sending JSON in API responses, minified JSON (no whitespace) reduces payload size and transfer time. Most web frameworks do this automatically, but you can also pipe through JSON.stringify(data) without the spacing arguments.

Prettify for readability. When debugging, editing config files, or reviewing diffs in version control, formatted JSON with proper indentation makes structure visible at a glance. Git diffs in particular benefit enormously from one-property-per-line formatting.

Frequently asked questions

Is JSON the same as a JavaScript object?
No, JSON is stricter. Property names must be double-quoted, trailing commas aren't allowed, and values like undefined, functions, and NaN aren't valid. A JavaScript object literal like { name: "hello" } is valid JS but invalid JSON — it should be { "name": "hello" }.
Can JSON have comments?
Standard JSON (RFC 8259) does not support comments. JSON5 and JSONC (used by VS Code for settings files) extend the format to allow single-line (//) and multi-line (/* */) comments. If you need comments in configuration, consider YAML or JSON5 instead.
What's the maximum size of a JSON file?
There's no limit in the specification. In practice, browser JSON.parse() handles files up to several hundred MB. This tool processes everything locally in your browser, so the limit is your device's available memory. For very large files, consider streaming parsers like JSONStream in Node.js.
What's the difference between JSON and YAML?
YAML is a superset of JSON that adds features like comments, multi-line strings, anchors, and aliases. It's popular for configuration files (Docker Compose, Kubernetes manifests, GitHub Actions workflows). JSON is more common for API responses and data interchange because it's simpler to parse and has fewer ambiguities.