Code Complexity Analysis
Analyze code metrics including cyclomatic complexity, nesting depth, and lines of code.
Code Input
Complexity Grade Guide
AComplexity 1-5: Simple, easy to test and maintain
BComplexity 6-10: Moderate complexity, consider refactoring
CComplexity 11+: High complexity, strongly recommend refactoring
Usage Guide
This tool analyzes code complexity metrics to help developers identify functions that need refactoring, improving code maintainability.
Features
- Count total lines, code lines, comment lines, and blank lines
- Identify functions and calculate cyclomatic complexity, nesting depth, lines, and parameter count for each
- Assign A/B/C grades based on cyclomatic complexity (A: 1-5 simple, B: 6-10 moderate, C: 11+ complex)
- Support JavaScript/TypeScript and other C-like syntax code
Steps
- Paste the code to analyze in the input area
- Click "Sample" to load example code for a demo
- View the top stat cards for overall complexity
- View the function analysis table to locate the most complex functions
- Focus on functions graded B/C for priority refactoring
Notes
- Analysis is based on text matching; support for non-C-like syntax (e.g., Python) is limited
- !Nesting depth is calculated by curly braces
{, not applicable to indentation-based languages - Cyclomatic complexity counts decision keywords (if/else/for/while/case/catch/&&/||/?)
- All calculations are done locally in the browser; code is not uploaded to any server
Related tools
More from the same category · Developer Tools
Cron ExpressionVisual Cron builder: pick minute-hour-day-month-weekday fields and preview next run times live.JSON FormatterJSON beautify, minify and validate with auto error location for missing brackets and stray commas.Timestamp ConverterConvert Unix timestamps to dates and back with second/millisecond precision and live current time.Regex TesterTest regex with live match highlighting, capture groups and substitution, toggling g/i/m/s flags.JWT ParserSplit a JWT into header, payload and signature, then base64url-decode claims and expiry without a key.JWT GeneratorIssue JWTs with custom header, claims and expiry across HS256, RS256, ES256 for auth-flow testing.