JSON formatter

Paste JSON to instantly format, validate, and beautify it.

Formatted JSON will appear here...

How JSON formatting works

JSON (JavaScript Object Notation) is a lightweight, human-readable data interchange format built on two structures: objects (key-value pairs in curly braces) and arrays (ordered lists in square brackets). Valid JSON follows strict syntax rules: keys must be double-quoted strings, values can be strings, numbers, booleans, null, arrays, or objects, and trailing commas are not allowed.

This formatter parses your input using JSON.parse() — if parsing fails, the exact error and character position are shown, making it easy to locate the problem. Valid JSON is then re-serialized with JSON.stringify(input, null, 2) for 2-space indentation. Common JSON errors include: single quotes instead of double quotes, trailing commas after the last item, unquoted keys, and missing commas between entries. The formatter also minifies JSON by removing all whitespace, which reduces payload size for APIs. All processing happens in your browser — no data is sent to any server.

Frequently asked questions

What is JSON?

JSON (JavaScript Object Notation) is a text-based data format used to store and transmit structured data. It is the dominant format for web APIs, configuration files, and data exchange between systems. JSON is language-independent but uses conventions familiar from JavaScript.

Why is my JSON invalid?

Common reasons: single quotes used instead of double quotes, trailing comma after the last item in an object or array, unquoted property keys, incorrect nesting, or special characters not properly escaped. The formatter shows the exact error position to help you locate the issue.

What is the difference between JSON and a JavaScript object?

A JavaScript object can have unquoted keys, single-quoted strings, undefined values, and trailing commas. JSON is stricter: all keys must be double-quoted strings, and only specific value types are allowed (string, number, boolean, null, array, object). JSON.parse() converts a JSON string into a JavaScript object.

Can this formatter minify JSON?

Yes. Minification removes all whitespace (spaces, tabs, newlines) from JSON to reduce its size. This is useful when sending JSON in API requests or responses where bandwidth matters. Minified JSON is functionally identical to formatted JSON — only human readability differs.

Related tools

Base64 → JWT decoder → URL encoder →