Developer tools

JSON Formatter

Free, public, and built for quick JSON cleanup.

Input

Paste JSON, then choose an action.

0 / 12,000
1

Validation appears here as you type.

§

What is JSON?

JSON (JavaScript Object Notation) is the most widely used data interchange format on the web. Every API response, configuration file, and database document likely uses JSON under the hood.

JSON Syntax Rules

Key-value pairs

Data in double-quoted keys: "name": "value"

Value types

Strings, numbers, booleans, null, arrays [], or objects {}

No trailing commas

Unlike JavaScript, the last item must not have a comma after it.

No comments

Use a separate documentation file or YAML if you need inline comments.

Common JSON Errors

Trailing comma
Wrong
{
  "name": "Alice",
  "age": 30,
}
Correct
{
  "name": "Alice",
  "age": 30
}
Single quotes
Wrong
{ 'name': 'Alice' }
Correct
{ "name": "Alice" }
Unquoted keys
Wrong
{ name: "Alice" }
Correct
{ "name": "Alice" }

How to Format JSON

1

Paste your JSON

Copy your raw JSON string and paste it into the input editor. The formatter accepts both minified and partially formatted JSON.

2

Choose an action

Click Format to pretty-print with 2-space indentation, Minify to compress to a single line, or Validate to check for syntax errors.

3

Review errors

If validation fails, error messages show the exact line and column where the problem occurs, along with a description of the issue.

4

Fix or copy

Use AI Assist to auto-repair common errors, or copy the formatted output directly to your clipboard.

JSON vs YAML vs XML

FeatureJSONYAMLXML
CommentsNoYesYes
ReadabilityHighVery HighLow
File SizeSmallSmallLarge
API UseStandardConfigLegacy

FAQ

What is JSON and why does formatting matter?+

JSON (JavaScript Object Notation) is a lightweight data interchange format used by APIs, databases, and configuration files. Proper formatting with consistent indentation, spacing, and line breaks makes JSON human-readable and easier to debug. Minified JSON is used in production to reduce payload size.

What are the most common JSON syntax errors?+

The most common errors are: trailing commas after the last item in an array or object, single quotes instead of double quotes, unescaped special characters in strings, missing quotes around keys, and comments (which are not valid JSON). A good formatter highlights these errors with line and column numbers.

What is the difference between JSON and JavaScript objects?+

JSON is a text-based data format that looks similar to JavaScript object literals but is stricter. JSON requires double-quoted keys, does not allow functions or undefined values, does not support comments, and has no trailing commas. JavaScript objects are more flexible but cannot be directly transmitted over APIs.

When should I minify JSON vs keep it formatted?+

Use formatted (pretty-printed) JSON during development for readability and debugging. Use minified JSON in production API responses and configuration files to reduce file size and network transfer time. Minification typically reduces JSON size by 20-40%.

Is JSON valid YAML?+

Yes, YAML 1.2 is a superset of JSON. Any valid JSON document is also valid YAML. However, YAML has additional features like anchors, aliases, and unquoted strings that are not part of the JSON specification.

What is the maximum nesting depth for JSON?+

The JSON specification (RFC 8259) does not define a maximum nesting depth. However, most parsers default to limits between 64 and 512 levels to prevent stack overflow attacks. Deeply nested JSON is usually a sign that the data structure should be flattened.

About JSON Formatter

Paste or type JSON into the Monaco editor. The tool provides instant formatting and minification using deterministic local parsing. Validation highlights errors with line-level detail.

If your JSON is malformed, click AI Repair to let AI fix common issues like trailing commas, missing quotes, or truncated input. No AI runs unless you explicitly request it.

  • Local deterministic formatting and minification.
  • Validation with detailed error messages.
  • Optional AI repair for broken JSON.
  • Powered by the Monaco editor.

More tools