๐Ÿ› ๏ธ Developer ยท Updated October 11, 2026 ยท 9 min read

Format JSON and Validate It: Indents, Sorting, Tree View

Messy Formatted ๐Ÿงท

To format JSON, paste it into GrabCast's JSON Formatter and click Beautify: the one-line blob becomes an indented outline with one field per line, and the syntax is validated before anything is rewritten, so a broken payload is flagged with a line, a column and a caret instead of being mangled. That covers the basic question. Making a 300 KB API response or a data-export file genuinely readable takes a little more: choosing an indent your team uses, sorting keys so two versions can be compared, and jumping straight to the one value you need instead of scrolling. This guide serves two readers at once. Developers and support engineers get indent conventions, key sorting for clean diffs and JSONPath. Marketers, analysts and no-code builders who meet webhook payloads in Zapier, Make, Shopify or Stripe get a five-minute primer on reading the structure and a safe way to check that the data is intact.

๐Ÿงท Try the JSON Formatter tool now โ€” freeOpen โ†’
JSON Formatter with the order payload beautified at 4 spaces, sorted keys and a valid status line
Minified input on top, indented and sorted output below.
๐Ÿ’ก Why readable, validated payloads save hours

Almost every modern app exchanges data in this format, and machines send it minified. A single Shopify order can arrive as 8,000 characters on one line; an Instagram or Google account download holds dozens of such files. Unformatted, the missing field you are hunting for is invisible, and two responses with keys in a different order look different even when they are identical. Formatting turns that wall of characters into an outline you can scan in seconds, and the validation step answers the first question in every broken automation: is the data itself damaged, or is the problem somewhere else in the chain? Knowing that early saves a lot of back and forth in code reviews, support tickets and incident calls.

How to format JSON and check it in one pass

Paste text into the input box, drop a .json or .txt file on it, or click Open file for anything up to 50 MB. Checking starts as you type, so you know whether the input is sound before you press a single button.

New to the notation? There are only six kinds of value. Curly braces hold an object of named fields, square brackets hold a list called an array, text sits in double quotes, numbers such as 19.99 are bare, true and false are lowercase switches, and null means empty or unknown, which is not the same as zero. Each step of indentation means you are inside the object or list above, so a price indented three levels deep belongs to one line item, not the whole order.

Choose an indent style, then sort keys for clean diffs

No indent is correct in the abstract; a consistent one is. Two spaces is the default in npm's package.json, Prettier and most JavaScript projects. Four spaces is familiar from Python, where json.dumps(data, indent=4) is a common idiom. Tabs let each reader pick their own width.

Find one value in a big file with the tree and JSONPath

Scrolling 20,000 lines is slow and error-prone. The Tree tab shows the same data as collapsible nodes that render their children only when opened, so multi-megabyte exports stay responsive, and each collapsed node shows how many keys or items it holds.

For a list of flat records you want in a spreadsheet, GrabCast's CSV to JSON converter also works in reverse and produces rows Excel or Google Sheets can open.

What formatting can change, and what validation cannot see

Beautifying means parsing and writing the data back out, and a JavaScript parser has limits you should know before pasting formatted output into a live system.

Everything above runs inside your browser tab. Customer emails, addresses and tokens in a webhook are not uploaded, though your company's data policy still decides where such records may be opened.

If your config is in YAML rather than JSON, convert it first with the YAML to JSON converter and then format it as above.

Step-by-step

1234
1Open the JSON Formatter and paste the payload, or use Open file or drag and drop for files up to 50 MB; validation runs while you type.
Minified order payload for order A-20931 pasted into the JSON input box on one long line
Paste the payload (or open a .json file); it is validated as you type.
2Read the status line: a green valid message means the data is intact, while a caret marks where parsing stopped so you can fix it or press Repair.
Indent set to 4 spaces with Sort keys ticked; status shows Valid JSON, 20 keys, depth 4, 595 B
Pick 2 spaces, 4 spaces or Tab, tick Sort keys, then click Beautify.
3Pick 2 spaces, 4 spaces or Tab, tick Sort keys if you will compare versions, and click Beautify.
Beautified order JSON with 4-space indentation and sorted keys: createdAt, customer, items, orderId
The formatted result is readable at a glance โ€” copy it or download a .json file.
4Use the Tree tab or a JSONPath query such as $..email to reach the values you need, then copy the output or download it as a .json file.
Tree view of the order with collapsible customer, items and shipping nodes and the JSONPath hint
Switch to Tree to collapse noise and click a key to copy its JSONPath.

Common mistakes to avoid

โš ๏ธCommitting beautified output with a different indent than the repository uses, producing a diff where every line changed.
โš ๏ธComparing two payloads without sorting keys first, then chasing differences that are only key order.
โš ๏ธTreating null as zero in a report, when it means the value is missing and should be left out of averages and totals.
โš ๏ธRound-tripping records with 64-bit IDs as numbers, silently corrupting the last digits.

Pro tips

โœ“Save a JSONPath query for each API you debug often, such as $..errors, so failures jump out of any response.
โœ“Beautify with Sort keys before saving test fixtures, which keeps future diffs small and reviewable.
โœ“When asking a colleague about a field, send its path, like $.customer.email, instead of a screenshot.
โœ“Bookmark the formatter next to your automation dashboard; checking a failing step's payload first resolves many integration tickets.
โœ“Compact the output again before pasting it into environment variables or query strings, where line breaks cause errors.

Frequently asked questions

What is the best indent for formatted data?

Two spaces is the most common convention in web projects and tools like Prettier; four spaces is common in Python. Matching your codebase matters more than the choice itself.

How do I know whether my data is valid?

Paste it into the JSON Formatter. A green Valid JSON message confirms the syntax; otherwise a caret shows the line and column where the parser gave up.

Does sorting keys change my data?

No. Objects are unordered by specification, so sorting changes only presentation, and arrays keep their order. The one caution is files where people rely on a hand-made key order.

Can I open the files from my Instagram or Google data download?

Yes. Open or drop a file up to 50 MB, browse it in the Tree tab, and use the query tab to pull out fields such as timestamps or captions across the whole file.

Is my data uploaded when I beautify it?

No. Parsing, repair, the tree view and JSONPath queries all run in your browser, so API keys or customer records stay on your machine.

๐Ÿ“Œ Bottom line

Let the validator confirm the data is intact, beautify with the indent your team uses, sort keys whenever you compare versions, and reach deep values through the tree or a JSONPath query instead of scrolling. Watch for large integers and duplicate keys, which any JavaScript-based formatter handles lossily, and remember that valid syntax is not the same as correct content.

Open the JSON Formatter tool โ†’

Related guides

Browse more: all text and developer guides ยท the JSON Formatter tool