JSON Truncator

Shrinks a large or deeply nested JSON document to a manageable size by capping how many levels deep it recurses, how many items of each array it keeps, and how many characters of each string it keeps, marking every truncation point so it's obvious the output is partial. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-24

Overview

Introduction

Large API responses or deeply nested config files are often too big to paste into a chat window, log line, or bug report in full.

This tool shrinks a JSON document down to a representative sample by capping depth, array length, and string length independently, while marking exactly where it cut.

What Is JSON Truncator?

A three-way size limiter for JSON: a maximum nesting depth, a maximum number of items kept per array, and a maximum number of characters kept per string.

Each limit is applied independently and recursively, so a document can be simultaneously too deep, too wide, and too verbose, and this tool addresses all three at once.

How JSON Truncator Works

The tool parses the input, then recursively walks the value tracking the current depth; once depth reaches the configured maxDepth, any object or array at that point is replaced entirely with the string __truncated__ instead of being expanded further.

Below that depth, arrays are sliced to maxArrayItems with a summary note appended if items were cut, strings longer than maxStringLength are sliced and given a trailing ellipsis, and every other scalar passes through unchanged.

When To Use JSON Truncator

Use it before pasting a large API response into a support ticket, chat message, or LLM prompt where only the shape and a sample of the data matters.

It's also useful for quickly previewing an unfamiliar, very large JSON file without your editor choking on rendering it in full.

Features

Advantages

  • Controls three independent size dimensions (depth, array length, string length) in one pass.
  • Marks every truncation point explicitly rather than silently dropping data.
  • Always produces valid, re-parseable JSON output.

Limitations

  • Truncation is lossy and one-directional; there's no way to reconstruct the original document from the truncated output.
  • The default limits (depth 3, 10 array items, 200 characters per string) are a starting point, not a universal fit; tune them for your specific document.

Examples

Truncating a deep, wide document

Input

{"users":[{"id":1,"name":"Ada"},{"id":2,"name":"Bob"},{"id":3,"name":"Cy"}]}

Output

{
  "users": [
    {
      "id": 1,
      "name": "Ada"
    },
    {
      "id": 2,
      "name": "Bob"
    }
  ]
}

With maxArrayItems set to 2, only the first two user objects are kept (the truncation-count note is omitted here since only 1 item was cut, but would appear as a trailing string entry for larger overages).

Best Practices & Notes

Best Practices

  • Set maxDepth generously if you mainly care about trimming huge arrays, not nested structure.
  • Lower maxStringLength first when the problem is a few enormous base64 or text blob fields, not overall structure.
  • Keep the original document around; treat truncated output as a preview, not a working copy.

Developer Notes

Depth-limiting happens before the array/string limits are applied at that same level, so a container exactly at maxDepth is replaced wholesale with __truncated__ rather than being partially sliced; this keeps the truncation boundary unambiguous instead of producing a half-truncated container.

JSON Truncator Use Cases

  • Shrinking a large API response for a bug report or support ticket
  • Previewing an unfamiliar large JSON file's shape before writing code against it
  • Trimming verbose base64 or text fields for a readable log excerpt

Common Mistakes

  • Setting maxDepth too low and losing the structural information you actually needed to see.
  • Forgetting the output is lossy and accidentally treating it as the real data in a script.

Tips

  • Use Find JSON Depth first to see how deep a document actually goes before picking a maxDepth.
  • If you only need the shape (keys and types), JSON Analyzer or JSON Schema Generator may be a better fit than truncation.

References

Frequently Asked Questions