Skip to content

JSON Formatter

Paste your JSON to format, validate, and beautify it instantly with syntax highlighting.

JSON formatter & validator

Empty
Paste or drop JSON below to get started.
Input Paste · drag-drop · upload · URL
Output
Formatted

        
        
      

Worked 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

Unexpected token ,
Trailing comma after the last element. Remove the final comma — JSON does not allow them (unlike JavaScript or JSON5).
[1, 2, 3,]
[1, 2, 3]
Unexpected token '
Strings must use double quotes, including keys. Replace single quotes with double quotes throughout.
{'name': 'Ada'}
{"name": "Ada"}
Unexpected identifier
Object keys must be quoted. {name: "x"} is valid JavaScript but not JSON.
{name: "Ada"}
{"name": "Ada"}
Unexpected end of input
A bracket or brace was never closed. Count the opens vs closes — the tree view’s fold arrows make this easier to spot.
{"a": [1, 2
{"a": [1, 2]}
Bad control character
A literal newline or tab inside a string. Escape them with \n / \t, or use a multi-line-friendly format upstream.
{"msg": "line1
line2"}
{"msg": "line1\nline2"}
Duplicate key (warning)
Not technically invalid, but 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

JSON (JavaScript Object Notation) is a lightweight data interchange format that has become the standard for web APIs, configuration files, and data storage. It is language-independent, human-readable, and easy for machines to parse and generate.

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

Always use double quotes: Single quotes are invalid in JSON. Both keys and string values must be wrapped in double quotes ("key", not 'key').
No trailing commas: A comma after the last item in an array or object is a syntax error. Remove it or your JSON will fail to parse.
Validate before sending: Always run your JSON through a validator before sending it to an API. A missing quote or extra comma can cause silent failures.
No comments allowed: Standard JSON does not support comments. If you need comments in config files, use JSONC (JSON with Comments) or JSON5 instead.
Keys must be unique: Within the same object level, each key should appear only once. Duplicate keys cause unpredictable behavior — most parsers keep the last value.

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.

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.

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).

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.

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.

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.

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.

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).

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.

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.