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

  • Data is in key-value pairs with double-quoted keys: "name": "value"
  • Values can be 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. 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. 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. 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. 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%.

More tools