Why raw JSON is hard to read
A single-line API response with forty levels of nesting is valid JSON and nearly impossible to read. Servers strip whitespace because machines do not need it: the JSON grammar treats spaces, tabs, and newlines between tokens as insignificant, so frameworks serialize compactly by default to save bytes on the wire.1 Consequently, the payloads you most often need to inspect, such as webhook bodies, error responses, and configuration exports, usually arrive as one unbroken line.
What JSON actually is
JSON stands for JavaScript Object Notation, a text-based, language-independent
serialization format built from exactly two
structures.1 An object is an unordered collection of
name-value pairs, and an array is an ordered list of values. Every value inside
either structure is a string, a number, an object, an array, or one of exactly
three literal names: true, false, and null.
One consequence surprises people regularly. A complete JSON text can be any
single value, so a bare number or a quoted string pasted on its own is valid
JSON, not only the braced and bracketed documents you see in API payloads.
That grammar explains most of this validator's strictness. The parser accepts exactly those values and nothing else, which is the strictness behind the failures this page catalogs: comments, unquoted keys, and single quotes are natural in JavaScript source, and each is absent from the grammar enforced here. The same two structures also describe the entire tree view. Every node the tree renders is one object, one array, or one scalar, which is why expanding a branch always resolves into one of those three shapes and nothing else, no matter how deep the nesting goes.
Formatting rebuilds the structure from scratch
Formatting restores the structure your eyes need. When you paste text into the input, the tool parses
it with the browser's native JSON.parse and re-serializes the result through
JSON.stringify with the indent you chose, so the output is always a faithful re-encoding
of the parsed data rather than a line-by-line reflow of the original text.2
Nested objects indent one level per depth, and every key lands on its own line, so the indentation itself turns into a map of the document's shape. At a glance you can trace a value from its top-level key down through each layer of nesting, which is exactly the kind of orientation a single unbroken line of JSON never gives you.
JSON and XML solve different problems
XML and JSON differ at the design level, not just the syntax level. XML is a document markup language: its units are tags, attributes, and namespaces, and it was designed to carry whole documents in which prose and inline markup interleave freely. JSON is a data serialization format with two structures and named values, and it carries no attributes and no mixed content at all. That contrast maps onto natural homes. Documents a human reads, with prose and markup woven through them, suit XML's machinery; data a program exchanges, with fields and values and nothing else, suits JSON's two structures.
Why did APIs move to JSON then? Three practical reasons did most of the work. The same payload carries less text, because tags repeat the field name at both ends of every value while a JSON key appears once. A parsed document maps directly onto native objects in every mainstream language, which spares an integration from a translation layer. Everyday exchange also needs no schema machinery at all, so the ceremony XML requires buys nothing in the common case. XML keeps the ground where its strengths matter, including document publishing, mixed-content markup, and the older standards built on top of it.
Formatting a Messy API Response
API responses are the most common one-line JSON you will paste into the formatter. The guide below explains why servers send responses without whitespace to save bytes on the wire, how to choose an indent width for the way you plan to use the formatted output, and what to do when a response is too large to read comfortably in the text view alone.
A copied API response usually arrives as one unbroken line. Servers strip whitespace before sending JSON over the wire, since the grammar treats spaces and newlines between tokens as insignificant, and every byte removed is a byte the network never has to carry.1 That habit is good for bandwidth and bad for your eyes the moment you need to actually read what came back.
Why the response you copied looks like one long line
Open your browser's network panel after any API call and the response body usually renders as a single dense string. Frameworks serialize this way by default: JSON.stringify with no third argument produces the most compact valid output, and most server-side JSON encoders follow the same convention because it saves real bandwidth at scale.2 A payload with forty nested fields becomes unreadable at that density, even though every character in it is perfectly valid JSON.
Pasting that line into this tool's input runs it through the browser's native JSON.parse, then re-serializes the result with JSON.stringify using whichever indent you picked. Consequently, the output is never a cosmetic reflow of your original text; it is a faithful rebuild of the same parsed data, just spaced out so nesting becomes visible at a glance.
Reading structure back into a flat string
Once indentation exists, each nesting level lines up under its parent key, so a value buried five layers deep shows its whole path just by looking at the left margin. That structural view is exactly what a single-line response destroys, and it is the first thing worth restoring before you try to debug anything inside the payload. Restoring that path is the whole reason to reach for a formatter instead of squinting at raw, unindented text.
Choosing an indent width for how you plan to use the output
Three indent options exist because different destinations call for different widths. A 2-space indent keeps deeply nested API responses compact enough to fit on screen without excessive horizontal scrolling, which is why it is the default most JSON tooling ships with, including Prettier, one of the most widely used code formatters.3 Four spaces reads more comfortably in a printed document or a walkthrough where every level needs to stand out clearly, at the cost of pushing deeply nested values further to the right.
Matching indent to a shared context
Tabs render at whatever width your own editor or terminal is configured for, so pasting tab-indented output into a codebase that already uses tabs keeps the formatting consistent with everything around it. If you are debugging on your own machine, the choice barely matters. If you are pasting the formatted result into a bug report, a Slack thread, or a wiki page, matching the indent your teammates already use in that context saves them from re-formatting it themselves.
Every indent option produces byte-identical *data*; only the surrounding whitespace differs. Switching between them costs one click and never risks altering a key or a value, so there is no reason to settle for the first option before checking whether a different width reads better for your specific screen. Try 4-space or Tab whenever 2-space output still feels cramped on a wide monitor.
When a response is too large for the text view alone
Some API responses, particularly paginated list endpoints or GraphQL results with several nested resolvers, run to thousands of lines once indented, since a GraphQL server's response always mirrors the shape of the client's original nested query.4 At that size, scrolling through formatted text to find one value stops being practical, which is exactly the gap the tree view fills: it renders your parsed data as collapsible nodes, and every object or array shows its key or item count before you ever expand it.
Working through deeply nested payloads
Large arrays and objects render their first 500 children immediately and load 100 more per click, so a response with thousands of entries never freezes the tab while it builds. If your response nests a list inside a list inside an object, as most paginated APIs do, expanding only the branch you actually care about is far faster than scanning a wall of indented text for the right closing brace.
Because parsing and tree construction both run in your browser, and inputs over roughly 500 KB move into a background Web Worker automatically, nothing about pasting a large production response sends it anywhere.5 That matters in particular for API responses, which routinely carry session tokens, internal IDs, or customer data you would not want to hand to a server-backed formatter.
Use this guide any time a raw API response arrives as one dense line and you need to read its structure, pick an indent, or browse it as a tree before you debug or document it.
A compact webhook payload pasted as-is
{"event":"order.created","data":{"id":"ord_9f3a","total":48.5,"items":[{"sku":"A1","qty":2},{"sku":"B7","qty":1}]}} The same payload with 2-space indent: every key sits on its own line, the two items inside "items" line up under their shared parent, and the nesting depth of "id" versus "sku" is visible without counting braces.
Both versions parse to the exact same JavaScript object. Only the whitespace between tokens changed.
A response too large to scroll comfortably
A paginated endpoint returns 2,000 order records in one array, and the formatted text view runs to over 40,000 lines.
Switching to Tree view collapses the array to a single "items: Array(2000)" node. Expanding it renders the first 500 records with a button to load 100 more, so you can inspect the shape of one record without scrolling past the other 1,999.
- 1.
T. Bray, Ed., "The JavaScript Object Notation (JSON) Data Interchange Format," RFC 8259, IETF, December 2017. https://www.rfc-editor.org/rfc/rfc8259
- 2.
MDN Web Docs, "JSON.stringify()," developer.mozilla.org, accessed August 2026. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
- 3.
Prettier, "Options: Tab Width," prettier.io, accessed August 2026. https://prettier.io/docs/options
- 4.
GraphQL Foundation, "Response," graphql.org, accessed August 2026. https://graphql.org/learn/response/
- 5.
WHATWG, "HTML Standard: Web workers," html.spec.whatwg.org, accessed August 2026. https://html.spec.whatwg.org/multipage/workers.html
No. The tool re-serializes the exact data your browser parsed, so keys and values come back unchanged. One caveat: equivalent number formats normalize, so 1e2 in your input becomes 100 in the output, because JSON.stringify always produces the canonical form for a given number.
If your server logs the pretty-printed version with a different indent width, or with keys re-ordered by its own serializer, the visible spacing differs even though the underlying data matches. Compare the tree view's key/value pairs directly if you want to rule out an actual data difference.
Yes. GraphQL responses are themselves standard JSON, typically wrapped in a top-level data key with one field per query alias. The formatter and tree view treat that structure exactly like any other nested JSON object.
Yes. CapyToolkit doesn't upload anything you paste: parsing, formatting, and the tree view all run inside your browser tab using the built-in JSON.parse function. You can disconnect from the internet after the page loads and formatting keeps working exactly the same way.
Strip the wrapping function call first, since the validator checks strict JSON as defined by RFC 8259 and a JSONP callback wrapper is JavaScript, not JSON. Once only the object or array literal remains, paste that portion in.
How the validator pinpoints syntax errors
Browser engines disagree about how to describe a broken document. Chrome and Edge, both built on V8, typically report the character position of the failure and, in recent versions, a line and column; Firefox reports a line and column of the JSON data; Safari often names only the unexpected token.34 Because of that inconsistency, most online validators simply print whatever the engine said and leave you to count characters yourself.
Turning a raw offset into a line and column
This tool normalizes the message instead. When the error text carries a line and column, the validator reads them directly; when it carries only a character offset, the tool walks your input, counts newline characters up to that offset, and derives the line and column itself. The result feeds a Jump to error button that focuses the input and selects the offending line, so the cursor lands exactly where the fix belongs.
The four mistakes behind most failures
In practice, four mistakes cause most failures: a trailing comma after the last member, a missing comma between members, an unquoted key, and single quotes where the grammar requires double quotes. All four are typos rather than design errors, which is why the fix is usually a one-character edit. Each one produces a different engine message, yet all four resolve in seconds once the failing line is selected right in front of you.
A trailing comma is the easiest to see in practice. Paste {"a": 1,} and
parsing stops at the closing brace that follows the comma, because JSON.parse
treats a comma with no following member as a syntax error rather than a harmless trailing
token the way JavaScript object literals allow. The engine's message and the derived line and
column therefore point at the brace, not at the comma itself, and the Jump to error button
selects that entire line so the offending comma sits inside the selection. Deleting that
single character so the input reads {"a": 1} turns it into valid JSON
that parses and formats cleanly on the next keystroke.
Reading large payloads with the tree view
Text is the wrong shape for a five-megabyte document. Past a certain size, the useful question is no longer what line 40,000 says but what lives under a particular key, and a collapsible tree answers that far faster than scrolling. The tree view renders your parsed data as expandable nodes, with each object showing its key count and each array showing its item count before you ever open it.
Under the hood, the tree is built lazily: a node's children do not exist in the DOM until the first time
you expand that node, and any object or array with more than 500 children renders the first 500 plus a
button that loads 100 more per click. Building DOM nodes, not parsing, is what freezes a tab on large
documents, so deferring construction keeps even huge payloads responsive. Inputs over roughly 500 KB
also parse inside a background Web Worker, which keeps typing and scrolling smooth while the document is
processed.5
Finding one value in a big document
One boundary deserves plain words before you paste something enormous. This viewer has no search box and no query language. Nothing here accepts a path expression or a query filter of any kind, and the tree exists for shape and navigation rather than lookup, so a five-megabyte paste arrives with the right expectations only if you know that up front. The split is deliberate. A query engine and a fast, lazy, collapsible reader are different projects, and this page is the reader, built to open huge payloads smoothly rather than to sift them.
The practical path for a needle is the text view plus your browser. The formatted output is ordinary rendered text in the page, so your browser's built-in find bar locates any substring in it immediately. The workflow for one specific value is short: format the document, stay in Text view, and run find in page, with the tree reserved for questions of shape and structure. Query-shaped work beyond substring hunting belongs to the command-line route a later section of this page describes, where filters and scripted pipelines do the sifting this viewer leaves out.
Pretty print or minify
Pretty output is for people and minified output is for machines. Indented JSON makes code review, debugging, and documentation legible, while minified JSON strips every insignificant byte before a payload ships over the network or lands in a size-limited configuration field. The toggle switches instantly between the two because both render from the same parsed value, and the indent control offers 2-space, 4-space, or tab indentation for the pretty form.
What re-serialization normalizes
One honest caveat applies to both modes. Since the output is a re-serialization of the parsed data,
equivalent representations normalize: the number 1e2 comes back as 100,
escape sequences may be rewritten in canonical form, and when an object contains the same key twice,
JSON.parse keeps only the last value, which the specification explicitly
permits.67 Your data is
unchanged, but its textual spelling may differ from the input.
Key order deserves its own line in that caveat. Formatting preserves the
order your keys arrived in, with one exception the serializer imposes: keys
that look like array indices, such as "0", "3", or
"42", jump ahead of every other key and sort numerically among
themselves. Paste {"b": 1, "2": 2, "a": 3} and the
output leads with the "2" entry, while the ordinary string keys
keep the positions you gave them. A document that mixes index-like keys
with named keys is therefore the one that visibly reorders, which is why
most payloads never notice the rule at all.
The same job outside the browser
This same pretty-print-and-validate job runs outside the browser tab.
jq's default filter exists to validate and pretty-print its input, and its
filter language builds pipelines that reshape payloads on the way
through.8 Python's
json module covers scripting needs and doubles as a
command-line validator and pretty-printer.9
On Windows, PowerShell's ConvertFrom-Json and
ConvertTo-Json cmdlets convert between JSON text and objects
for automation.10 Each route
works on files already on your disk and prints its result where the next
command can read it, so a scripted pipeline can format, check, and
transform payloads without a page ever opening.
The browser route still wins for the work this page does best. A one-off inspection needs no shell history and no local files: you paste or drop the payload, read the result, and close the tab. The tree view turns shape exploration into clicks, which plain text output does not offer. And the payload never leaves the tab, which matters when the JSON you are inspecting carries credentials or customer data. The terminal wins when the files already live on disk, when the output feeds the next command in a chain, and when the same transformation runs on a schedule. The two routes complement rather than compete.
Your JSON never leaves the browser
Pasting production payloads into a random website is a real risk. API responses routinely contain session tokens, email addresses, and internal identifiers, and a server-backed formatter receives all of it the moment you paste. This tool takes the opposite approach: parsing, formatting, validation, and the tree view all execute inside your browser tab, and no request carries your input anywhere.
Everything the formatter does relies on primitives your browser already ships: JSON.parse
and JSON.stringify for the data work, and a Web Worker for keeping big parses off the main
thread.25 After the page loads you can
disconnect from the internet entirely and every feature keeps working, which is also the simplest way
to verify this claim for yourself. No account, API key, or server round trip sits between your paste
and the result, so the only copy of your data is the one already in your own tab.
Well-Formed JSON Checklist
- No trailing commas A comma after the last item or property is invalid JSON, unlike JavaScript object literals.
- Commas between every member A missing comma between two properties or array items is one of the most common paste errors.
- Keys are double-quoted Unquoted keys are valid in JavaScript object literals but not in strict JSON.
- Double quotes, not single quotes JSON strings and keys must use double quotes; single quotes are rejected.
Paste your own JSON above — the validator jumps to the first line that breaks one of these rules.
- 1.
T. Bray, Ed., "The JavaScript Object Notation (JSON) Data Interchange Format," RFC 8259, IETF, December 2017. https://www.rfc-editor.org/rfc/rfc8259
- 2.
Ecma International, "ECMA-262: ECMAScript® Language Specification," ecma-international.org, accessed July 2026. https://ecma-international.org/publications-and-standards/standards/ecma-262/
- 3.
MDN Web Docs, "JSON.parse()," developer.mozilla.org, accessed July 2026. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse
- 4.
MDN Web Docs, "SyntaxError: JSON.parse: bad parsing," developer.mozilla.org, accessed July 2026. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/JSON_bad_parse
- 5.
WHATWG, "HTML Standard: Web workers," html.spec.whatwg.org, accessed July 2026. https://html.spec.whatwg.org/multipage/workers.html
- 6.
Ecma International, "ECMA-404: The JSON Data Interchange Syntax," 2nd edition, ecma-international.org, December 2017. https://ecma-international.org/publications-and-standards/standards/ecma-404/
- 7.
Ecma TC39, "JSON.parse source text access," tc39.es, November 2025. https://tc39.es/proposal-json-parse-with-source/
- 8.
jq project, "jq 1.8 Manual," jqlang.github.io, accessed September 2026. https://jqlang.github.io/jq/manual/
- 9.
Python Software Foundation, "json module documentation," docs.python.org, accessed September 2026. https://docs.python.org/3/library/json.html
- 10.
Microsoft Learn, "ConvertFrom-Json (Microsoft.PowerShell.Utility)," learn.microsoft.com, accessed September 2026. https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/convertfrom-json