Developer

JSON Formatter

Paste JSON to format, validate and minify instantly. Choose 2 or 4-space indent. 100% client-side.

INPUT
OUTPUT
1
Formatted output will appear here
A tangled line of curly braces turning into neatly indented JSON with a check mark

How to use

  1. Paste your JSON into the Input box, or click Sample to try an example.
  2. Click Format to indent it with 2 or 4 spaces, or Minify to squeeze it onto one line.
  3. If the JSON is invalid, the error shows the line and column, with suggestions for the usual causes. Turn on Skip errors to keep the last valid result on screen while you fix it.
  4. Click Copy to copy the result. Nothing you paste is sent anywhere, so it is safe for data that contains keys or personal details.

What a JSON formatter does

JSON (JavaScript Object Notation) is the text format most APIs, configuration files and apps use to exchange data. Machines often send it as one long line, which is hard to read. A formatter adds line breaks and indentation so each key and value sits on its own line, and checks that the text is valid JSON at the same time.

Minifying does the opposite: it removes every space and line break that is not inside a string, which makes the file smaller for sending or storing. Both keep the data exactly the same.

Common JSON errors and how to fix them

JSON is stricter than JavaScript. These five mistakes cause most "Unexpected token" errors.

ErrorInvalidValid
Trailing comma{"a": 1, "b": 2,}{"a": 1, "b": 2}
Single quotes{'name': 'Ann'}{"name": "Ann"}
Unquoted key{name: "Ann"}{"name": "Ann"}
Comment{"a": 1 // note}{"a": 1}
Missing comma{"a": 1 "b": 2}{"a": 1, "b": 2}

JSON data types

A JSON value can be an object in curly braces, an array in square brackets, a string in double quotes, a number, true, false or null. There is no date type, so dates are usually written as strings such as "2026-10-23T09:00:00Z", and numbers cannot have leading zeros or a trailing decimal point. Keys must always be strings in double quotes.

Frequently asked questions

Is it safe to paste JSON that contains API keys or customer data?

Yes. The formatter runs in your browser with JavaScript's built-in JSON parser, and nothing is uploaded or saved. Many online formatters send your text to a server; this one does not.

Should I use 2 or 4 spaces?

Either is valid. Two spaces is the most common choice for web projects and keeps deep nesting readable; four spaces is common in Python and some style guides. Pick what your team already uses.

Why does valid JavaScript fail here?

JavaScript object literals allow single quotes, unquoted keys, trailing commas and comments. JSON allows none of these, so code copied from a .js file often needs those small changes.

Can it handle large files?

Files of several megabytes format in a moment on a modern computer. Very large files are limited only by your device's memory, since nothing is sent to a server.

Found a problem or have an idea? Report a problem

Share

You might also like