JSON Formatter
Paste your JSON to format, validate, and beautify it instantly with syntax highlighting.
JSON formatter & validator
EmptyWorked examples
Click any card to load the payload into the editor.
What is JSON & how this tool works
JSON (JavaScript Object Notation) is a lightweight text format for structured data. It uses six value types — string, number, boolean, null, object (keyed map), and array (ordered list) — and is supported by virtually every programming language.
This tool parses your input with the browser’s native JSON.parse, then re-renders it two ways. Format pretty-prints with the indent you choose (defaults to 2 spaces). Minify produces the shortest valid output — useful for embedding in URLs, config values, or assertion snapshots. Tree view gives you collapsible nodes and one-click JSON paths ($.data.users[0].name) that you can paste into tools like jq, JMESPath, or Postman’s test scripts.
The sort-keys toggle produces a deterministic key order so two payloads with the same content compare equal. Duplicate keys in your input are surfaced as a warning — the JSON spec doesn’t forbid them, but parsers silently keep only the last occurrence, which is a common source of bugs.
Common JSON errors
,[1, 2, 3,]
[1, 2, 3]
'{'name': 'Ada'}
{"name": "Ada"}
{name: "x"} is valid JavaScript but not JSON.{name: "Ada"}
{"name": "Ada"}
{"a": [1, 2
{"a": [1, 2]}
\n / \t, or use a multi-line-friendly format upstream.{"msg": "line1
line2"}
{"msg": "line1\nline2"}
JSON.parse keeps only the last value — silent data loss. Rename or merge the keys.{"id": 1, "id": 2}
{"ids": [1, 2]}
Examples
How It Works
Valid JSON follows strict syntax rules: all keys must be double-quoted strings, values can be strings, numbers, booleans, null, arrays, or nested objects. Trailing commas after the last item are not allowed, and comments are not part of the standard. These rules make JSON unambiguous — any compliant parser will interpret the same data identically.
Pretty-printing adds indentation and line breaks to make JSON readable. Minifying strips all unnecessary whitespace to reduce file size for transmission. This tool parses your JSON, validates it against the spec, and re-serializes it with syntax highlighting so you can inspect structure, spot errors, and copy clean output.
Tips & Best Practices
Frequently Asked Questions
What is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based data format used for storing and exchanging structured data. It uses key-value pairs and arrays, is human-readable, and is the standard format for web APIs and configuration files.
How do I validate JSON?
Paste your JSON into the formatter and it will automatically check for syntax errors. Valid JSON will be formatted with proper indentation. If invalid, the tool highlights the exact line and character where the error occurs.
What are common JSON syntax errors?
The most frequent errors are: trailing commas after the last item in an object or array, using single quotes instead of double quotes, unquoted keys, missing commas between items, and including comments (JSON does not support comments).
What is the difference between JSON and JavaScript objects?
JSON is stricter than JavaScript objects: keys must be double-quoted strings, values cannot be functions or undefined, and trailing commas are not allowed. JSON is a data format, while JavaScript objects are programming constructs.
Can JSON contain comments?
Standard JSON does not support comments. If you need comments in configuration files, consider JSONC (JSON with Comments, used by VS Code) or JSON5, which extends JSON with comments, trailing commas, and unquoted keys.
What is JSON Schema?
JSON Schema is a specification for defining the structure, types, and constraints of JSON data. It lets you validate that a JSON document conforms to an expected format — for example, requiring certain fields to be present or limiting values to specific types.
How do I handle dates in JSON?
JSON has no native date type. The most common convention is to use ISO 8601 strings (e.g. "2024-01-15T09:30:00Z"). Unix timestamps (seconds or milliseconds since epoch) are also popular. Always document which format your API uses.
What is the maximum size of a JSON file?
JSON itself has no size limit, but practical limits depend on the parser and environment. JavaScript's JSON.parse() can handle files of several hundred megabytes. For very large datasets, consider streaming parsers or formats like NDJSON (newline-delimited JSON).
What is the difference between JSON and XML?
JSON is more compact and easier to parse than XML. JSON uses key-value pairs and arrays, while XML uses nested tags with attributes. JSON is the dominant format for web APIs due to its simplicity, while XML is still used in enterprise systems, SOAP services, and document formats.
What is pretty-printing?
Pretty-printing adds indentation, line breaks, and spacing to minified JSON to make it human-readable. Minified JSON removes all unnecessary whitespace to reduce file size for transmission. Both represent the same data — the difference is purely visual.