JSON Formatter / Validator

Client-side only

Format, prettify, and validate JSON instantly. Minify JSON, fix common errors, and spot syntax issues with line and column numbers. All in your browser.

Input JSON
Output

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, human-readable data interchange format. It is the dominant format for APIs, configuration files, and data storage in modern web development. JSON represents data as key-value pairs, arrays, strings, numbers, booleans, and null values.

Raw JSON from APIs is often minified — all whitespace stripped out — making it nearly impossible to read. A JSON formatter adds proper indentation and line breaks to make the structure clear. A JSON validator checks for syntax errors and tells you exactly where the problem is.

JSON has strict syntax rules: keys must be quoted strings, trailing commas are not allowed, and undefined, functions, and comments are not valid JSON values. These rules differ from JavaScript object literals, which trip up many developers.

How to Use This Tool

  1. Paste your JSON into the Input panel on the left.
  2. Click Format JSON to pretty-print it with indentation, or Minify to strip all whitespace.
  3. If your JSON has a syntax error, the error panel below the output shows the exact line and column of the problem.
  4. Use the indent selector to switch between 2-space, 4-space, or tab indentation.
  5. Click Copy to copy the formatted output to your clipboard.

Common Use Cases

Debugging API Responses

Paste minified API responses to instantly make them readable and spot issues in the data structure.

Validating JSON Config Files

Check JSON configuration files (package.json, tsconfig.json, etc.) for syntax errors before deploying.

Minifying JSON for Production

Strip whitespace from JSON to reduce payload size before embedding it in code or sending over the network.

Finding JSON Syntax Errors

The validator shows the exact line and column of any syntax error, saving time compared to manual inspection.

Formatting Webhook Payloads

Pretty-print incoming webhook payloads to understand their structure when building integrations.

Cleaning Up Copied JSON

JSON copied from logs or terminals often has inconsistent formatting — this tool normalizes it instantly.

Frequently Asked Questions

What is the difference between formatting and validating JSON?

Formatting (pretty-printing) adds indentation and line breaks to make JSON readable — it does not check for errors. Validating checks whether the JSON is syntactically correct according to the JSON specification. This tool does both simultaneously.

Why is trailing comma invalid in JSON?

The JSON specification (RFC 8259) strictly prohibits trailing commas after the last element in an array or object. This differs from JavaScript, where trailing commas are allowed. Many developers are caught by this when writing JSON by hand.

Can JSON contain comments?

No. Standard JSON does not support comments. If you need comments in a configuration file, consider JSONC (JSON with Comments, used by VS Code) or JSON5, but be aware that standard JSON parsers will reject them.

What is the difference between JSON and a JavaScript object?

JSON is a text format — it is always a string. A JavaScript object is a runtime data structure. JSON keys must be double-quoted strings; JS object keys can be unquoted identifiers. JSON does not support undefined, functions, Date objects, or circular references.

How do I fix 'Unexpected token' errors in JSON?

Common causes: trailing comma after the last item, single quotes instead of double quotes, unquoted keys, missing comma between elements, or JavaScript-style comments. The error message from this tool shows the exact location to check.

Want to learn more? Read our guide: How to Format and Validate JSON Online

Read →