How to Format JSON Online (and Fix Common Errors)

How to pretty-print, validate and minify JSON, what the most common JSON syntax errors mean, and how to fix them quickly — with safe, local tools.

JSON from an API or log file often arrives as one long line that is impossible to read. Formatting (also called beautifying or pretty-printing) adds line breaks and indentation so you can see the structure instantly. This guide covers formatting, validation and the errors you will meet most often.

Formatting JSON in three steps

  1. Open the JSON Formatter.
  2. Paste your JSON.
  3. Choose 2 spaces, 4 spaces or tabs, and copy the formatted result.

Before:

{"user":{"id":42,"name":"Ayesha","roles":["admin","editor"]},"active":true}

After:

{
  "user": {
    "id": 42,
    "name": "Ayesha",
    "roles": ["admin", "editor"]
  },
  "active": true
}

The optional sort keys setting orders object keys alphabetically, which makes it much easier to compare two responses with the Text Diff Checker.

The five most common JSON errors

1. Single quotes

JSON requires double quotes for strings and keys. {'name': 'Ali'} is valid JavaScript but invalid JSON. Replace with {"name": "Ali"}.

2. Trailing commas

{"a": 1, "b": 2,} fails because of the final comma. Remove the comma after the last item in objects and arrays.

3. Unquoted keys

{name: "Ali"} must be {"name": "Ali"}.

4. Comments

Standard JSON does not allow // or /* */ comments. Some configuration formats (JSONC, JSON5) do, but a strict parser rejects them.

5. Invalid values

undefined, NaN, functions and dates are not JSON values. Use null, numbers, or ISO date strings like "2026-11-14T10:00:00Z".

Reading error messages

Our JSON Validator reports the line and column where parsing failed, for example “Line 4, column 22: Expected double-quoted property name”. The actual mistake is often just before that position — such as a missing comma at the end of the previous line.

When to minify JSON

Minifying removes all whitespace. Use the JSON Minifier when embedding JSON in HTML attributes or environment variables, or storing it compactly. Over the network, servers normally compress responses with gzip or Brotli, so minifying saves less than the raw numbers suggest.

Is it safe to paste JSON into online formatters?

API responses often contain access tokens, email addresses or customer data. Many online formatters send your input to their servers. VIPTools.pk formatters use your browser’s built-in JSON.parse and never upload anything. Even so, avoid pasting live production secrets on shared machines, and rotate any key you think may have been exposed.

Formatting JSON in your own tools

  • JavaScript: JSON.stringify(data, null, 2)
  • Python: json.dumps(data, indent=2)
  • Command line: jq . file.json
  • VS Code: Shift + Alt + F (Windows) or Shift + Option + F (macOS)

New to the format itself? Read What Is JSON and Why Is It Used?

Found an error or have a suggestion? Contact us — see our editorial policy for how we write and update guides.

More guides

Need help?