Skip to main content

How to Format JSON Online (Without Sending It to a Server)

· 4 min read

Most developers eventually need to make a messy JSON blob readable — straight out of a curl response, a log line, or a Slack message. The usual answer is to paste it into an online formatter. The catch: a lot of those formatters POST your payload to their server, which is not what you want when the payload includes session tokens or PII.

This guide shows the workflow we use with our own JSON Formatter, which runs entirely in the browser.

The 30-second version

  1. Open /json-formatter.
  2. Paste the JSON in the input box.
  3. Click Format. The formatted version appears below.
  4. (Optional) Click Minify to round-trip back to one line.

That's it. The tool never makes a network request with your payload — you can verify by opening the Network tab in DevTools while you click Format.

When formatting matters

  • Code reviews. Diffing a one-line JSON blob is impossible. Format it first, commit the formatted version, and reviewers can read the change line-by-line.
  • Debugging API responses. A 4 KB payload with no whitespace is much easier to scan once it has line breaks and indentation.
  • Generating fixtures. Pretty-printing then trimming is faster than handcrafting nested structures.

Common pitfalls

  • Trailing commas. JSON does not allow them, even though JavaScript does. The formatter will report a syntax error pointing at the offending line.
  • Single quotes around keys. Same issue — JSON requires double quotes. Find/replace before pasting.
  • Big numbers. Integers above 2^53 lose precision when parsed as JavaScript Number. If your payload includes IDs in that range, wrap them in quotes before round-tripping.

Why client-side matters

If your payload contains anything sensitive (auth tokens, PII, internal IDs), pasting it into a tool that POSTs to a third party means that data is now in someone else's logs. We built /json-formatter so it never has the option — the JavaScript that does the formatting runs in your tab, full stop.

For the same reason, see Base64 Encoder and JWT Decoder, which follow the same model.