JSON Formatter & Validator

Format and validate JSON instantly. Pretty print with custom indentation or minify. Free online JSON formatter.

JSON (JavaScript Object Notation) is the most widely used data format in modern software development. REST APIs return JSON, configuration files are written in JSON, logs are structured as JSON, and databases store JSON documents. But JSON often arrives minified — stripped of all whitespace to reduce size — making it nearly impossible to read at a glance.

This tool pretty-prints JSON with configurable indentation so you can read and understand its structure immediately. Paste a minified API response and instantly see nested objects and arrays laid out clearly. Choose 2 spaces, 4 spaces, or tabs depending on your preference or project conventions.

The validator catches common JSON errors and reports the exact location of the problem. JSON is stricter than JavaScript object literals: property names must be double-quoted, trailing commas are not allowed, and undefined values are not permitted. If you copy JSON from a browser console or a code snippet, there may be subtle syntax issues that this tool will surface immediately.

The minify function removes all unnecessary whitespace to produce the smallest possible representation of your data. Use this before storing JSON in a database, sending it in an HTTP request body, or embedding it in source code where compactness matters more than readability. All operations run entirely in your browser; nothing is sent to our servers.

Indentation: 2 spaces, 4 spaces, or tabs?

The formatter supports three indentation styles, all of which produce valid JSON. Two spaces is the most common choice in JavaScript and frontend codebases and in most public APIs. Four spaces is more common in Python-adjacent tooling and in documentation where visual clarity matters more than byte count. Tabs are rare in JSON — only a few standards bodies prefer them, usually for accessibility reasons since tab width is a reader preference. Whichever you pick, pick one and be consistent within a project.

Common JSON syntax mistakes

Most "invalid JSON" errors trace back to a small set of mistakes that the validator flags immediately:

  • Single quotes. JSON strings must use double quotes. 'hello' is a JavaScript literal; the JSON spelling is "hello".
  • Trailing commas. [1, 2, 3,] is legal in modern JavaScript but illegal in JSON. Drop the comma after the last element of an array or the last key of an object.
  • Unquoted keys. {name: "ada"} is a JavaScript object literal; the JSON form is {"name": "ada"}.
  • Comments. JSON does not support // or /* */. If your config file allows them, you are reading JSONC or JSON5, not JSON.
  • Invalid numbers. NaN, Infinity, and leading zeros (07) are not valid JSON.

Format, minify, or parse?

These three operations look similar but serve different purposes. Formatting adds whitespace so humans can read the structure. Minifying strips whitespace for the wire. Both operations also act as a validation pass: if the input does not parse, the tool reports the exact position of the error. Parsing into a typed structure (a TypeScript interface, a Pydantic model) is the step your application does after the validation — it turns the raw JSON into objects the rest of your code can use.

Related reading

For a longer discussion of validating JSON beyond syntax — covering JSON Schema, boundary validation, and shape bugs — see our article on JSON validation best practices.

Frequently Asked Questions