Songtov Utility
Back to Home
Developer Tools

JSON Formatter

Paste raw JSON to validate and format it with proper indentation. 100% client-side — nothing is uploaded.

Unescape
Formatted output will appear here…

What is a JSON formatter?

A JSON formatter — sometimes called a JSON beautifier or pretty-printer — takes a minified or badly-indented JSON string and rewrites it with consistent whitespace so the structure becomes easy to scan. It also parses the input strictly, so any syntax error surfaces immediately with a precise message.

If you have ever copied an API response from a browser devtools network tab and ended up with a single 40-kilobyte line of text, you already know why formatting matters. The data is the same; the readability is not.

How to use this tool

  1. Paste your raw JSON into the Input panel on the left.
  2. Decide whether the Unescape toggle should be on. Leave it on if your JSON was copied from a log line or shell string where quotes are escaped with backslashes. Turn it off if your input is already clean JSON.
  3. Click Format JSON. The indented result appears on the right, or an error message if the input is invalid.
  4. Click Copy to put the formatted output on your clipboard.
  5. Click Clear to reset both panels.

Worked examples

Example 1 — a minified API response:

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

After formatting:

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

Example 2 — an escaped JSON string from a log line:

"{\"event\":\"click\",\"path\":\"/home\"}"

With Unescape on, the wrapper string is stripped and the inner JSON is formatted directly — you do not need to hand-edit backslashes.

Example 3 — a common mistake:

{
  "name": "Alice",
  "age": 30,
}

This fails with a message pointing at the trailing comma after 30. JSON does not allow trailing commas; remove it and re-run.

Common use cases

  • Debugging REST or GraphQL API responses during development.
  • Inspecting webhook payloads from third-party services (Stripe, GitHub, Slack).
  • Cleaning up minified JSON before committing a fixture file.
  • Turning an escaped log string back into readable JSON.
  • Validating the output of a code generator or template.
  • Teaching JSON structure to someone new to the format.

Frequently asked questions

Is my JSON sent to a server?

No. This tool runs entirely in your browser using native JavaScript. Your data never leaves your device, which makes it safe for pasting API responses, logs, or configuration fragments that contain sensitive values.

What does the Unescape toggle do?

When enabled, the formatter first strips an outer escape layer — for example, turning `"{\"key\":\"value\"}"` into `{"key":"value"}` before formatting. This is useful when you copy JSON out of log lines or shell strings where quotes have been escaped.

Why does my JSON fail to parse?

The most common causes are trailing commas after the last item in an object or array, single quotes instead of double quotes, unquoted keys, and inline comments. JSON has strict syntax and any one of these will make the entire document invalid.

Does it support large JSON files?

Yes, as long as your browser can hold the string in memory. Files in the tens of megabytes work on modern hardware. For very large payloads, consider streaming parsers on a server.

Does it support JSONC (JSON with comments)?

Not directly. Standard JSON does not allow comments. If your source is JSONC (for example, VS Code settings files), remove the `//` and `/* */` comments first, then format the result here.

Can I use this for YAML, XML, or Markdown?

No — this tool is specifically for JSON. It validates against the JSON grammar and will reject anything that is not valid JSON.

Related reading