JSON Truncator

Truncate large JSON to a manageable size. Limit by depth, keys per object, array length, and string length. Perfect for debugging huge API responses.

Input JSON
Truncated JSON

Features

📐 Depth Limiting

  • Set a maximum nesting depth
  • Deeper objects replaced with {"...": "..."}
  • Deeper arrays replaced with ["..."]
  • Default depth of 3 levels

🔑 Key & Array Limits

  • Keep only first N keys per object
  • Truncate arrays to first N items
  • Appended count of omitted entries
  • Set 0 for unlimited keys

📝 String Truncation

  • Trim long string values
  • Shows remaining character count
  • Configurable length threshold
  • Keeps all other value types intact

JSON Truncation Guide

How Truncation Works

All four truncation modes can be combined. The tool walks the JSON tree and applies each rule at each node:

  • Max depth — any node deeper than this level is replaced with a placeholder value.
  • Max keys — only the first N keys of each object are kept; a "..." key shows how many were omitted.
  • Max array items — only the first N elements of each array are kept; a trailing string item shows the omitted count.
  • Max string length — string values longer than N characters are sliced and appended with a char-count suffix.

Truncating JSON for logs, docs and LLM prompts

Real payloads are often far larger than anyone needs to read. Truncating keeps the structure recognizable while cutting size, which is ideal for bug reports, documentation examples and context passed to AI models.

Tips and common pitfalls

  • When sharing data with an LLM, keep a couple of array items as examples and drop the rest. The model learns the shape without paying for every record; see our LLM Token Counter to measure the savings.
  • Shorten long strings such as Base64 images or HTML blobs, which are usually noise when debugging.
  • Check the truncated output for personal data before sharing it; truncation shortens values but does not remove them.
  • Keep the original file. Truncated data is for reading, not for processing.

More questions

Why not just minify the JSON?

Minifying removes whitespace but keeps every value, so large payloads stay large. Truncation removes content while keeping the structure readable.

Is truncation useful for logging?

Yes. Logging a truncated body keeps log volume and cost down while still showing the request shape when debugging.