Cyclomatic Complexity Calculator
Analyze pasted JavaScript or TypeScript for cyclomatic complexity: per-function scores, risk grades, line numbers, and refactoring hints. Heuristic, in-browser.
Loading tool...
What is Cyclomatic Complexity Calculator?
The Cyclomatic Complexity Calculator scores pasted JavaScript/TypeScript functions with the classic complexity metric: one base path plus one point per branch, loop, case, catch, logical operator, and ternary. Each function gets a line number, a standard risk grade, and concrete refactoring hints for hotspots - all computed locally as you type.
Key Benefits
- Turns messy-code feelings into a ranked, numeric work list
- Standard risk grades match common refactoring conventions
- Hints escalate from extract-function to aggressive splitting
- String-aware scanning keeps scores close to full parsers
- Instant, private, offline analysis of pasted code
Common Use Cases
- •Triaging legacy functions before a refactor sprint
- •Checking new code against a team complexity budget
- •Reviewing pull requests for hard-to-test hotspots
- •Teaching clean-code principles with concrete scores
How to Check Code Complexity
- Paste your code: Drop in the JavaScript or TypeScript functions you want to assess.
- Read the scores: Each function gets a complexity score and risk grade - the highest scores are your refactoring targets.
- Follow the hints: Apply the extract-function hints on high-risk functions and re-paste until grades drop.
Key Features
- Per-function cyclomatic complexity scores with standard risk grades
- Counts branches, loops, cases, catches, logical operators, and ternaries
- Line numbers and names for every detected function
- Refactoring hints escalate at complexity 10 and 20
- Live analysis as you type or paste - no upload
- String-aware scanning to avoid counting keywords inside quotes