Every developer has opened a code review or a bug report and found a single line of JSON a thousand characters long. Somewhere inside it sits the one field that explains the bug. Nobody can see it. The reviewer scrolls sideways, gives up, and asks a question that a readable paste would have answered on sight.

Formatting is the fix, and it costs a minute. Paste the JSON into the free JSON Formatter and Validator on Ovatly, pick an indent, and the wall of text becomes a structure a reviewer can read, diff and point at. This guide explains why the formatting matters, how to do it, and what to strip out before the paste goes anywhere public.

Contents

  • Quick answer
  • Why one line defeats a diff
  • Indent: pick one width and keep it
  • How to format JSON for sharing, step by step
  • Worked example: the one-liner nobody can review
  • Before you share: take the secrets out
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

Paste the JSON into the JSON Formatter and Validator and format it with a 2 or 4 space indent, using the same width throughout. Every key lands on its own line, so a diff highlights only the fields that changed and a reviewer can cite an exact line. If the text will not format, run Validate only to get a plain-words error naming the problem. Before posting anywhere public, replace live secrets, tokens and personal data with placeholders.

Why one line defeats a diff

Reviews and bug reports run on diffs, and diffs compare line by line. That one fact decides whether your JSON helps or hinders. When a payload is a single line, the smallest change, one digit in one value, marks the entire line as changed. The reviewer sees a red line and a green line, each a thousand characters, and has to hunt for the difference character by character. Most will not. The change gets a rubber stamp or a confused question, and neither is a review.

Formatted JSON flips this. One key per line means one field per line, so a changed value lights up as exactly one changed line. An added field appears as added lines. A removed field is obvious. The structure does the explaining that you would otherwise have to write in prose, badly, while pointing at positions inside a line that has no positions.

There is a second, quieter benefit: line numbers. A reviewer who can say "line 14, the tools value is a string here and a number in the other paste" moves the conversation forward in one comment. A reviewer facing a single line can only say "somewhere in the middle," and the thread stalls.

Indent: pick one width and keep it

The formatter offers a 2 space or a 4 space indent. Two spaces keeps wide, deeply nested payloads narrower on screen. Four spaces makes each level easier to pick out at a glance. Neither is more correct, and arguing about them wastes more time than either would ever save.

What matters is consistency. Use one width across the whole snippet, and ideally the same width your team uses everywhere. Mixed indents, or a paste reformatted at a different width from the one it is compared against, make every line look changed and you are back to the wall of text problem, just taller.

How to format JSON for sharing, step by step

  1. Copy the JSON from wherever it lives: a log, a response, a config file. Copy it exactly; formatting is about presentation, not editing.
  2. Open the JSON Formatter and Validator and paste the text in.
  3. If it formats, choose your indent, 2 or 4 spaces, and format. If it refuses, run Validate only and read the plain-words error; fix the named problem in your copy, or report the invalid JSON itself if that is the bug.
  4. Read the formatted output once yourself. Check that the field you care about is present and visible, and that nothing sensitive is sitting in it.
  5. Paste the formatted version into the review or report, in a code block so the indentation survives.

Worked example: the one-liner nobody can review

Here is a small payload the way it usually gets pasted:

{"name":"Ovatly","tools":250,"free":true}

Nothing is wrong with this JSON. It is valid, complete, and useless in a review, because there is nowhere to point. The same payload, formatted with a 2 space indent:

{
  "name": "Ovatly",
  "tools": 250,
  "free": true
}

Now a reviewer can write "the tools value on line 3" and everyone lands in the same place instantly. If a second version arrives with tools as a string, the diff shows one line changing, and the type mismatch that was invisible in the one-liner becomes the whole story of the review.

Before you share: take the secrets out

Real payloads carry real secrets: access tokens, API keys, session values, customer details. A bug tracker, especially a public one, is exactly the wrong place for them. Before a paste leaves your machine, scan the formatted output (formatting helps here too, since every value sits on its own visible line) and replace sensitive values with harmless placeholders that keep the shape of the data. The structure is what the report needs; the live token is not.

Limitations and honest tradeoffs

Formatting changes whitespace and nothing else. It does not fix wrong values, rename fields, or repair structure; a payload with the wrong data in it formats beautifully and is still wrong. It also cannot format invalid JSON at all. Trailing commas, single-quoted strings, unquoted keys and comments all fail, because the standard is strict and the tool enforces it. That refusal is useful information, but it is a diagnosis, not a repair.

Two smaller points. Number precision follows JavaScript, so integers beyond 2^53 can lose exactness when the text is parsed and written out again; if an exact giant integer is the subject of the report, say so in the text rather than trusting the paste. And very large pastes, in the tens of megabytes, may take a moment to format, because the work runs locally in your browser.

Common mistakes

  • Pasting the one-line wall. The default way JSON arrives is the worst way to share it. Format first.
  • Pasting live secrets or tokens from a real payload into a public tracker. Replace them with placeholders before the paste leaves your machine.
  • Mixing indent widths. Two snippets at different indents diff as if everything changed. One width, everywhere.
  • Blaming the formatter when JSON will not format. Invalid input is the usual cause. Validate only, and read the error it names.
  • Minifying the report copy to save space. A report exists to be read. Save the compact form for machines.

FAQs

Why does one-line JSON hurt a code review? A diff tool compares line by line. When the whole payload is one line, any change marks the entire line as changed, and the reviewer cannot see which field moved. Formatted with one key per line, the same diff highlights only the lines that actually differ.

Should I use a 2-space or 4-space indent? Either works. Pick one and use it consistently across the whole snippet and, ideally, across your team. The formatter offers both; consistency matters more than the width, because mixed indents make diffs noisy again.

What should I remove before pasting JSON into a bug report? Remove or replace live secrets, access tokens, passwords and personal data from real payloads. A public tracker is public. Keep the structure and the field that shows the bug, and swap sensitive values for harmless placeholders.

Can formatting change the data? Formatting changes whitespace only: the keys, values and order stay the same. One thing to keep in mind is very large integers. Number precision follows JavaScript, so integers beyond 2^53 can lose exactness when the text is parsed and written out again.

The JSON I copied will not format. What now? It is probably not valid JSON. Run Validate only, which checks the text without changing it and reports the problem in plain words. Trailing commas, single-quoted strings, unquoted keys and comments are the usual causes, and none of them are valid JSON.

Conclusion

A minute of formatting decides whether a review thread moves or stalls: consistent indent, one key per line, secrets removed, and the JSON Formatter and Validator does the mechanical part in your browser. If the JSON you are sharing came from a webhook and you have not checked it yet, our guide to checking JSON from a webhook payload covers the validation step that should come first. For more guides in this series, see our Data and JSON Tools guides.

References