JSON Analytics — Analyze JSON Structure & Complexity
Analyze JSON structure with detailed metrics: key counts, nesting depth, data types, and complexity scores.
Input
Data Types
Complexity
Measuring JSON Complexity
A JSON payload with 50,000 keys and 20 levels of nesting will slow down your frontend, bloat your API responses, and make debugging painful. But you cannot tell this by reading the JSON — you need metrics. This tool analyzes the structural properties of any JSON document and produces a complexity score, key count, nesting depth, and type distribution.
Use these metrics to decide when to flatten nested objects, split large payloads, or refactor your API responses. The complexity score distills multiple dimensions into a single number you can track over time or use as a threshold in CI pipelines.
Understanding the Metrics
| Metric | What It Measures | Action Threshold |
|---|---|---|
| Total Keys | Number of properties across all objects | Over 1,000 keys may slow rendering |
| Max Depth | Deepest nesting level from root | Over 6 levels is hard to debug |
| Objects / Arrays | Count of containers in the structure | High ratio indicates complex nesting |
| Complexity Score | Combined score (0-100) from depth, keys, and nesting | Above 60 suggests refactoring needed |
Practical Scenarios
Scenario 1: API response too large for mobile
{
"users": [
{ "id": 1, "name": "Alice", "profile": {
"avatar": "...", "bio": "...", "settings": {
"theme": "dark", "notifications": {
"email": true, "push": true, "sms": false
}
}
}],
"total": 1500
} Analysis result:
Total Keys: 9
Max Depth: 4
Objects: 4
Complexity Score: 35 (Moderate) Recommendation: Flatten the settings object. Move notification preferences to a separate endpoint.
Using Complexity Scores in CI/CD
- Baseline measurement — run analytics on your current production payloads to establish a baseline
- Regression detection — compare metrics before and after API changes to catch complexity increases
- Threshold gating — fail builds that exceed a complexity threshold (e.g., score above 60)
- Type distribution checks — detect unexpected nulls or type conversions in imported data
Limitations
- The complexity score is a heuristic. A high score does not always mean poor performance — context matters.
- Documents over 10MB may slow the browser during analysis.
- Does not detect circular references or duplicate keys.
Frequently Asked Questions
How is the complexity score calculated?
Three factors are combined: depth score (0-30 points based on max depth), key score (0-30 points based on total keys), and nesting score (0-40 points based on object/array count). The sum is capped at 100. Lower scores indicate simpler structures.
What does a high score mean?
A score above 60 suggests deep nesting and many keys. This often means slower rendering, harder debugging, and larger payloads. Consider flattening nested objects or splitting the data into smaller responses.
Why is max depth different from what I counted?
Depth starts at 1 for the root object. {"a": 1} has depth 1. {"a": {"b": 1}} has depth 2. If you counted from 0, your number will be one less.
Can I compare two documents?
Run analytics on each document and compare the metrics. For a direct field-by-field diff, use the JSON Comparator.
What if my JSON is invalid?
The tool displays "Invalid JSON" and resets all metrics. Use the JSON Parser to validate first.
Next Steps
- Navigate the structure visually with JSON Tree Explorer
- Compare two versions of a document with JSON Comparator
- Validate your JSON before analysis with JSON Parser