JSON Formatter

Format (pretty print) or minify JSON online with 2 or 4 space indentation. Shows the line and column of syntax errors and keeps number precision.

Format or minify JSON first; the result is shown here as a tree.

How to use

  1. Paste your JSON into the Input box on the left, or click "Load example" to try it out.
  2. Click "Format" to pretty-print it with 2 or 4 spaces of indentation, or "Minify" to remove all whitespace and put it on one line.
  3. Use "Copy" or "Download" above the Result box to get the output.

Example

Minified JSON:

{"id":9007199254740993,"name":"Mike","tags":["vip","newsletter"]}

After formatting with 2 spaces:

{
  "id": 9007199254740993,
  "name": "Mike",
  "tags": [
    "vip",
    "newsletter"
  ]
}

What makes this formatter different

Repair, tree view and the editor

FAQ

Why do I get "Invalid JSON"?

The most common causes are:

  • A trailing comma after the last item, e.g. {"a": 1,}
  • Single quotes, e.g. {'a': 1}; JSON only allows double quotes
  • Unquoted keys, e.g. {a: 1}
  • Comments; standard JSON does not support // or /* */

The error message points to a line and column. Looking at and just before that position usually reveals the problem.

What is the difference between formatting and minifying?

The data is identical; only whitespace and line breaks differ. Formatted JSON is easier to read and compare. Minified JSON is smaller, which suits config files, URL parameters and API requests.

Is my data uploaded?

No. Formatting and minifying run in your browser and nothing is sent to the server. Your input is remembered only in your own browser, is removed automatically after 30 days without use, and is cleared immediately when you click "Clear".