Generate a call graph for an unfamiliar codebase to quickly understand how functions connect.
Find orphaned functions that nothing calls in a large Python or JavaScript project.
Visualize the structure of complex code before refactoring to see what depends on what.
Document how your application flows from its entry point through to its output as a diagram.
Requires Graphviz to be installed separately on your system in addition to the pip package.
Code2flow is a command-line tool that reads your source code files and produces a diagram showing which functions call which other functions. These diagrams are called call graphs, and they give you a visual map of how code flows from one piece to another. The tool supports Python, JavaScript, Ruby, and PHP. To use it, you install it via pip and point it at one or more source files. It outputs a DOT file, which is a standard format for graph diagrams, and renders it as an image using Graphviz, a separate free tool you also need to install. You can narrow the output to focus on a specific function and control how many levels of callers and callees to include. The tool can also be used as a Python library rather than from the command line. The tool works by parsing the source code into an internal structure, finding all function definitions, and then tracing where each function is called. Because Python, JavaScript, Ruby, and PHP are dynamic languages where values and types are only known at runtime, perfect accuracy is not possible. Code2flow documents its known limitations clearly: functions that share a name in different contexts may be skipped, anonymous functions and lambdas are skipped, and functions passed around as variables may not be traced correctly. The result is described as a pretty good estimate of project structure rather than an exact map. The tool is useful for developers trying to understand an unfamiliar codebase, identify functions that nothing calls (orphaned code), or untangle code that has grown complex over time. It can generate diagrams for a single file or an entire directory of source files. Code2flow is released under the MIT license and has 100% test coverage according to its own test suite.
← scottrogowski on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.