jsontoolskit.org
JSON and JSON Schema utilities, in the browser
Say hi →

Prune a Large JSON Document

max depth · max array · max string · max keys · reports what was cut

A 40 MB API response is not something you can read, paste into a ticket, or commit as a fixture. This cuts it down along four axes at once — nesting depth, array length, string length, keys per object — replacing what it removes with a placeholder that says how much went. The result is still valid JSON with the original shape recognisable, which is what makes it useful as a sample.

Paste input to start.

Which limit to reach for

  1. Max array length is almost always the first move. One array of ten thousand near-identical elements is the usual reason a document is unreadable, and three elements show the shape as well as ten thousand do.
  2. Max string length is where the bytes actually are in text-heavy data — a base64 blob, an HTML body, an embedded document. 120 characters keeps the value recognisable.
  3. Max depth replaces anything deeper than the limit with {12 keys omitted} or [400 items omitted], which keeps the top-level structure legible while cutting the bulk beneath it.
  4. Max keys per object is the rarest one, for objects used as dictionaries with thousands of entries.

Combine them. Arrays-then-strings is the usual pair, and it routinely takes a 40 MB payload under 20 KB with the structure fully intact.

A pruned document is a sample, not the data

Everything here is lossy by design. A truncated string is no longer the value; a capped array no longer has the element you were looking for; a collapsed subtree is a string where an object used to be. That is exactly right for reading, for a ticket attachment, for a test fixture that exercises a parser — and wrong for anything that consumes the content.

The placeholders are deliberately visible rather than silent, so nobody downstream mistakes a pruned document for a complete one. The status bar reports each kind of cut separately along with the size before and after; if it says nothing exceeded the limits, your document was already small and the limits are too generous.

Privacy

Nothing is uploaded. The pruning runs in this tab using your own browser's JavaScript engine — no server sees your data, and the page keeps working with the network disconnected.

FAQ

Is the output still valid JSON?

Yes. Strings are shortened, arrays are sliced, and collapsed subtrees become a string describing what was omitted. Every output parses. It will not validate against a schema that expected an object where a placeholder string now sits.

How is this different from the minifier?

Minify removes whitespace and changes nothing about the data — the document still contains everything. This removes data. Minify when you want the same document smaller on the wire; prune when you want a smaller document.

Can I keep a specific branch at full depth?

Not in one pass. Extract the branch you care about with JSON Pointer or jq first, prune the rest, and keep the two side by side in your ticket.

Does it prune keys inside collapsed subtrees?

They are not visited at all — the whole subtree is replaced at the depth limit, so its contents never appear in the output and its cost never appears in the size.