Free, browser-based utilities for everyday developer workflows

Format JSON for API logs and debugging

API logs print JSON as one long minified line. Pretty-print it to read the structure, validate it to find the exact syntax error, and sort keys for stable diffs — all locally.

Open this example in JSON Formatter

Open the tool, then paste the sample input below. Everything runs locally in your browser.

Open this example in JSON Formatter →

The problem

Structured logs emit JSON on a single line so a log shipper can store it. That is unreadable to a human chasing a bug. You need to expand it, confirm it actually parses, and ideally normalize key order so you can diff two events side by side.

Sample input

Minified log line
{"level":"error","ts":"2026-06-14T10:22:01Z","msg":"payment failed","ctx":{"orderId":"A-1001","amount":4200,"currency":"usd"}}

Expected output

Prettified (2-space)
{
  "level": "error",
  "ts": "2026-06-14T10:22:01Z",
  "msg": "payment failed",
  "ctx": {
    "orderId": "A-1001",
    "amount": 4200,
    "currency": "usd"
  }
}

Same data, now readable. The nested ctx object is where the order details live.

How to do it

  1. Copy the minified JSON log line.
  2. Paste it into the formatter.
  3. Choose an indentation, such as 2 spaces.
  4. Prettify and read the structure.
  5. Fix any reported syntax error at the shown line and column.

Common mistakes

  • Copying a partial line so the JSON is truncated and will not parse.
  • Log lines that are JavaScript object literals (single quotes, unquoted keys) rather than JSON.
  • Embedded escaped JSON strings that need a second pass to expand.
  • Trailing commas left in after hand-editing.
  • Assuming a 200-line file is invalid when only one line is the bad one.

Related tools

Related guides

FAQ

How do I read a minified JSON log line?

Paste the single-line JSON into the formatter and prettify it. Indentation and line breaks make the structure readable without changing any values.

How do I find the syntax error in broken JSON?

The formatter validates as you paste and reports the exact line and column of the first error, such as a trailing comma or an unquoted key.

Can I sort keys to get a stable diff between two log entries?

Yes. Sorting object keys makes two semantically equal payloads serialize identically, so a later diff only shows real changes.

Why is my log JSON not valid JSON?

Logs often contain JavaScript object literals with single quotes, comments, or unquoted keys. Those are not valid JSON; quote keys and use double quotes to fix them.

Is my log data uploaded anywhere?

No. Parsing, formatting, and validation all run locally in your browser. Nothing is sent to a server.

JSON formatting runs locally in your browser. No log data is uploaded.

Explore more JSON and API contract tools

Format, diff, query and validate JSON and API payloads — grouped in one place.

View the JSON & API contract toolkit →