Overview
Introduction
Before you dig into a large or unfamiliar YAML file, it helps to know its shape: how deep it's nested, how many keys it has, and what kinds of values it actually contains. This tool parses a document and reports exactly that, without you having to scroll through the whole thing.
It's especially useful for auto-generated configs (Helm output, exported Kubernetes manifests) where you don't know the structure ahead of time and want a quick orientation before reading line by line.
What Is YAML Statistics?
A YAML statistics tool walks a parsed document and tallies structural facts about it: how many mapping keys exist in total, the deepest level of nesting, and how many leaf values fall into each scalar type.
It also reports simple text metrics, line count and character count, which are useful for gauging whether a document is small enough to review by hand or large enough to warrant filtering with another tool first.
How YAML Statistics Works
The input is parsed with a full YAML 1.2 parser, then the resulting value is walked recursively. Every mapping and sequence increments an object or array counter respectively; every scalar leaf increments a counter for its type (string, number, boolean, or null); and the recursion tracks the deepest depth reached.
Line and character counts are computed directly from the raw input text, independent of parsing, so they reflect the document exactly as pasted.
When To Use YAML Statistics
Use it when you're handed an unfamiliar YAML file and want a quick sense of its size and shape before reading it top to bottom.
It's also useful for sanity-checking a generated or templated config, an unexpectedly high nesting depth or key count can be an early signal that a template loop went wrong.
Often used alongside YAML Diff Checker, YAML Structure Visualizer and YAML Validator.
Features
Advantages
- Gives an instant structural overview without manually scrolling through the document.
- Runs entirely client-side, so large or sensitive configs never leave your browser.
- Separates object and array counts, useful for understanding whether a config leans on mappings or lists.
- Surfaces nesting depth, a useful early warning sign for overly complex configuration.
Limitations
- Comments are counted toward line count but not analyzed or included in any other statistic.
- Only the first document in a multi-document (`---`-separated) YAML stream is analyzed.
- Key counting treats every occurrence of a key at every nesting level as distinct; it does not report a separate 'unique key names' statistic.
Examples
Best Practices & Notes
Best Practices
- Check nesting depth first when reviewing an unfamiliar file, it tells you how much scrolling and indentation-tracking to expect.
- Use the leaf-type breakdown to spot configuration that's unexpectedly all strings, sometimes a sign that numbers or booleans were quoted unintentionally.
- Combine with the YAML Diff tool when comparing statistics before and after a refactor, to confirm the structure actually simplified.
Developer Notes
The counting walk is structurally identical to this site's JSON Analyzer, adapted to use `parseYaml` from `yaml-core` instead of `JSON.parse`. Depth for a top-level scalar (a document that's just `42` or `"hello"`) is reported as 0 since there's no mapping or sequence to descend into.
YAML Statistics Use Cases
- Getting oriented in a large, unfamiliar Helm values file
- Sanity-checking the output of a config-generating script or template
- Comparing the complexity of two versions of the same config before and after a refactor
- Quickly confirming whether a document is mostly scalars, mappings, or sequences
Common Mistakes
- Assuming 'total keys' means unique key names, it counts every key occurrence at every level, so a key like `name` appearing in three different objects counts three times.
- Treating line count as a proxy for complexity, a long document with a shallow, flat structure can have far more lines than a deeply nested but compact one.
- Forgetting that comments inflate the line count without appearing anywhere else in the statistics.
Tips
- A high max depth relative to a small key count often signals deeply nested single-key wrappers, worth flattening for readability.
- Use this before running the YAML Diff tool on two large files to gauge how much output the diff might produce.
- Pair with Extract Keys from YAML if you need the actual key names, not just the count.