JSON Structure Analyzer

Analyze JSON structure metrics: count objects, arrays, keys, max depth, and detect issues like repeated keys and inconsistent types

Paste valid JSON to see structural metrics including object count, array count, key count, max depth, and detected issues.

Analyzing JSON Structure and Complexity Metrics

Understanding the structural complexity of JSON documents helps teams make informed decisions about API design, database schema choices, and data processing strategies. A JSON payload that appears simple at the surface may contain deeply nested objects, inconsistent array element types, or thousands of repeated keys that indicate denormalization issues or schema drift. The JSON Structure Analyzer provides a bird's-eye view of your document's composition — counting objects, arrays, keys, measuring maximum nesting depth, and detecting structural anomalies.

Paste any JSON document and receive comprehensive metrics: total node counts by type, maximum and average nesting depth, key frequency analysis, array homogeneity checks, and potential issues like repeated keys within objects or inconsistent types across array elements. These insights inform whether a response payload needs pagination, whether a nested structure should be flattened, or whether schema validation is needed to catch structural drift.

Structural Metrics and Counts

The analyzer computes key metrics that describe document complexity:

  • Total nodes: Combined count of all objects, arrays, and primitive values
  • Object count: Number of {} containers in the document
  • Array count: Number of [] containers with their element counts
  • Maximum depth: The deepest nesting level (objects within objects within arrays)
  • Average depth: Mean nesting level across all leaf values
  • Unique keys: Total distinct property names used across all objects
  • Total string length: Combined character count of all string values

These metrics immediately reveal whether a document is shallow and wide (many top-level keys), deep and narrow (deeply nested single paths), or balanced — each pattern suggesting different processing strategies.

Detecting Structural Issues

Beyond metrics, the analyzer identifies structural patterns that may indicate problems:

  • Repeated keys: The same key appearing multiple times within a single object (valid JSON per spec but usually a bug, later values overwrite earlier ones)
  • Inconsistent array types: Arrays containing mixed types (strings and numbers, or objects with different shapes) suggesting missing schema validation
  • Oversized arrays: Arrays with hundreds or thousands of elements that may indicate missing pagination
  • Excessive depth: Nesting beyond 10-15 levels suggests over-denormalization or recursive data structures
  • Empty containers: Empty objects {} or arrays [] that may indicate null handling issues

Use Cases for Structure Analysis

Structure analysis serves several development workflows:

  • API design review: Evaluate whether response payloads are appropriately sized and structured for client consumption
  • Schema validation planning: Identify which parts of a JSON structure need validation rules based on inconsistency patterns
  • Performance optimization: Find oversized arrays that need pagination or deeply nested structures that need flattening
  • Data migration planning: Understand source data complexity before designing target schemas
  • Documentation: Generate structural summaries for API documentation describing expected response shapes

Code Examples

Structure Analysis Output Example

// Input: Complex API response
// Analysis output:
{
  "metrics": {
    "totalNodes": 1247,
    "objects": 89,
    "arrays": 23,
    "strings": 456,
    "numbers": 312,
    "booleans": 67,
    "nulls": 12,
    "maxDepth": 7,
    "avgDepth": 3.2,
    "uniqueKeys": 42
  },
  "issues": [
    {
      "type": "inconsistent-array",
      "path": "$.users[*].metadata",
      "detail": "Array contains both objects and strings"
    },
    {
      "type": "oversized-array",
      "path": "$.events",
      "detail": "Array has 500 elements — consider pagination"
    }
  ]
}

Frequently Asked Questions

What does the JSON Structure Analyzer do?

The JSON Structure Analyzer examines your JSON content and reports structural metrics: the total number of objects, arrays, keys, and the maximum nesting depth. It also detects potential issues like repeated keys, inconsistent types within arrays, and oversized arrays.

What are repeated keys and why do they matter?

Repeated keys occur when the same key appears more than once in a single JSON object (e.g., {"name": "A", "name": "B"}). While technically valid JSON syntax, most parsers silently discard all but the last value for a duplicate key. This can lead to subtle bugs where data is unexpectedly lost.

What counts as inconsistent types in an array?

An array has inconsistent types when its elements are of different types — for example, mixing strings and numbers (["hello", 42]) or mixing objects with primitives. While valid JSON, inconsistent types can cause issues in strongly-typed languages and make schemas harder to define.

What is an oversized array?

An array with more than 100 elements is flagged as oversized. This is an informational warning since large arrays can indicate data that might be better paginated, stored separately, or processed with streaming instead of loading entirely into memory.

How is nesting depth calculated?

The root value is at depth 0. Each level of nesting (entering an object or array) increases the depth by 1. For example, in {"a": {"b": [1]}}, the number 1 is at depth 3. Deep nesting can indicate overly complex data structures.

What is the difference between JSON Explorer and JSON Structure Analyzer?

JSON Explorer provides an interactive tree view for navigating and searching JSON content. JSON Structure Analyzer provides quantitative metrics about the overall structure — counts, depth, and potential issues — giving you a bird's-eye view of JSON complexity without interactive navigation.

Is my JSON data sent to a server?

No. All analysis happens entirely in your browser using JavaScript. Your JSON content is never transmitted to any server. No data is stored, logged, or shared.

What are the input size limits?

The tool warns when input exceeds 500KB (processing may be slow) and rejects input larger than 5MB. These limits ensure the browser remains responsive during analysis.