JSON Formatter, Validator & Beautifier

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based format for storing and exchanging structured data. It was derived from JavaScript object syntax but is now language-independent — every major programming language can parse and generate it. JSON is the default data format for REST APIs, web application configuration files, browser storage (localStorage), and most modern databases and cloud services.

A JSON file is any plain-text file containing valid JSON data, typically with a .json extension. Common examples include package.json (Node.js project settings), tsconfig.json (TypeScript configuration), and API response bodies saved to disk for debugging or testing.

JSON syntax: objects, arrays, and square brackets

JSON has two container types that are easy to confuse:

The most common confusion is using square brackets when you need curly braces or vice versa. Use [ ] when you have a list of things; use { } when you have named properties. Arrays and objects can be nested freely: {"colors": ["red", "green"]} is an object with an array value.

Pretty-print vs. minify

Pretty-printing (formatting) adds consistent indentation and newlines to make JSON human-readable — useful for debugging, reviewing API responses, and reading configuration files. Minifying strips all whitespace to produce the most compact representation, which reduces payload size when transmitting JSON over a network. The data is identical either way; only the whitespace differs.

JSON escaping

The escape action converts a JSON string into a version safe for embedding inside another JSON string literal — double quotes become \", backslashes become \\, and control characters are replaced with their escape sequences (\n, \t, etc.). This is useful when building JSON-in-JSON payloads or serializing JSON for storage in a database field. Unescape reverses the process.

Common JSON validation errors

JSON5 and JSONC

If your configuration file uses comments or trailing commas, it is likely JSON5 or JSONC (JSON with Comments) rather than strict JSON. These formats extend JSON syntax for human-authored files and require their own parsers — they are not valid standard JSON and will fail with a standard JSON.parse() call.

Frequently asked questions

What is the difference between [] and {} in JSON?

Square brackets [] create a JSON array — an ordered list of values. Curly braces {} create a JSON object — a set of named key-value pairs. Use arrays for lists of things (items, results, tags); use objects for records with named properties (a user, a config, an event).

What is a JSON file?

A JSON file is any plain-text file that contains valid JSON data, usually saved with a .json extension. Common examples: package.json, tsconfig.json, API responses saved for testing, and application settings. JSON files can be opened in any text editor and parsed by any language with a standard library.

What is the difference between a JSON formatter and a JSON beautifier?

They are the same thing — different names for the same operation. "Formatting," "pretty-printing," and "beautifying" all mean adding indentation and line breaks to make JSON easier to read. This tool does all three, along with minifying (compacting), validating, and escaping JSON.

Why does my JSON fail to validate?

The most common causes: trailing comma after the last property or array item, single quotes instead of double quotes, unquoted object keys, comments in the file (// or /* */), or a bare string/number where an object or array is expected. Paste your JSON above and click Validate — the error message will point to the exact line and character.

What is the difference between JSON and XML?

JSON and XML both represent structured data, but JSON is more compact, easier to read, and natively supported by JavaScript. XML uses opening and closing tags (<name>value</name>) and supports attributes and namespaces — making it more verbose but more expressive for document-oriented data. REST APIs almost universally use JSON; older SOAP services and configuration formats (Maven, Android resources) still use XML.