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.
Often used alongside JSON Analyzer, JSON Nesting Depth Finder and JSON Minifier.
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
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.