Code Complexity Analyzer

Measure cyclomatic complexity, nesting depth and length of every function in JavaScript, TypeScript, PHP, Python, Java, C#, C++ and Go. Find code that is hard to test.

Tool

Was this tool useful?

About this tool

About Code Complexity Analyzer

Paste code or choose files to see which functions are the hardest to read, test and change. For each function the analyzer counts cyclomatic complexity (the number of paths through it), the deepest nesting and the number of parameters and lines, and rates it from Simple to Very complex. Strings and comments are ignored. Sort out the worst functions first and export the table as CSV.

How it works

Cyclomatic complexity = 1 + number of decision points (if, else if, for, while, case, catch, &&, ||, ??, ?:). 1–10 simple, 11–20 moderate, 21–50 complex, over 50 very complex.

Example

A function with one if, one for loop and one && has complexity 1 + 3 = 4.

How to use this tool

  1. Paste code or choose one or more files.
  2. Check the language (detected automatically).
  3. Read the table – start refactoring the functions with the highest numbers.

Frequently asked questions

What is a good complexity number?

Aim for 10 or less per function. Above 20, a function needs many tests to cover every path and is easy to break.

Is it exact?

It is a fast count of keywords and operators in the source, not a full compiler. Results are very close to tools like ESLint’s complexity rule for normal code.

Does it run my code?

No – it only reads the text.

Is my data uploaded?

No. Everything is processed in your browser and stays on your device.

Does the Code Complexity Analyzer send my data to a server?

No. The Code Complexity Analyzer runs entirely in your browser using JavaScript, so tokens, code and data you paste stay on your device. You can even use it offline once the page has loaded.