Paste any code snippet to get a rough, heuristic read on its cyclomatic complexity, nesting depth, comment ratio, and overall maintainability — a quick gut-check, not a substitute for a real static analysis tool.
Paste a code snippet to see its complexity estimate
This tool gives you a rough, at-a-glance read on how complex and maintainable a code snippet is — without needing to install a linter, configure a static analysis tool, or even know what language you're looking at. Paste in any snippet and it immediately estimates cyclomatic complexity, maximum nesting depth, comment coverage, and average line length using simple text-pattern heuristics, then combines complexity and nesting into a single Simple / Moderate / Complex / Very Complex maintainability rating. It's built for quick sanity checks — skimming a pull request, deciding whether a function needs refactoring, or getting a fast second opinion before diving into a proper code review — not as a replacement for real static analysis tooling.
Lines of code are counted by splitting the snippet on line breaks and discarding blank lines; comment lines are identified by checking whether a trimmed line starts with a common comment marker (//, #, /*, *, or --), and the comment ratio is comments ÷ non-blank lines. Cyclomatic complexity starts at 1 (representing a single straight-line path through the code) and adds 1 for every occurrence of a decision-point keyword or operator — if (which also naturally covers every else if, since that still contains the word "if"), for, while, case, catch, elif, &&, ||, and the ternary ?: operator — found via word-boundary regex matches across the whole snippet. Nesting depth is estimated by measuring each line's leading whitespace (tabs expanded to spaces), detecting the most common non-zero indentation step between distinct indent levels, and dividing the deepest indentation found by that step size.
High cyclomatic complexity and deep nesting are strongly correlated with code that's harder to test, harder to reason about, and more likely to contain bugs — every additional decision point roughly doubles the number of distinct paths a reviewer or test suite needs to cover. A quick heuristic score like this one can't replace a real code review, but it's a fast, zero-setup way to flag a function that's grown too tangled and might be worth breaking into smaller pieces before it becomes a maintenance burden.
Counts independent decision paths through code. Lower is simpler to test and reason about; functions above ~10 are commonly flagged as candidates for refactoring in real static analysis tools.
How many levels of indentation (if-inside-if-inside-loop, etc.) a snippet reaches. Deep nesting makes code harder to follow and is often a sign that logic should be extracted into separate functions.
The share of lines that are comments versus code. Useful as a rough documentation signal, though quality matters more than quantity — a few clear comments beat many redundant ones.
Common questions about this complexity estimator
Explore other developer & tech tools