Skip to content
Fallow home
All docs pages

madge alternative: compare madge with fallow

Compare madge with fallow for circular dependencies, orphan files, and dependency graphs in TypeScript and JavaScript. See which madge command maps to which fallow command.

madge makes a visual graph of your module dependencies and finds circular dependencies. Fallow also finds circular dependencies and draws the import graph. It also reports unused code, duplication, and complexity in the same run. This page maps the madge commands to fallow commands, and lists what each tool does better.

fallow migrate does not read .madgerc or the madge field in package.json. Most madge options control the graph style or the module resolution, and fallow has no equivalent settings for them. Fallow finds the entry points and the tsconfig.json path aliases automatically.

Command mapping

madgeFallow
madge --circular src/fallow architecture --cycles
madge --orphans src/fallow dead-code --unused-files (see Orphans and unused files)
madge --leaves src/-- (no equivalent)
madge --depends <module> src/fallow dead-code --trace-file <path> (the imported-by list)
madge --image graph.svg src/fallow viz --viz-format dot | dot -Tsvg -o graph.svg
madge --dot src/fallow viz --viz-format dot
madge --json src/-- (no JSON dump of the full graph. Use fallow viz --viz-format mermaid or fallow dead-code --trace-file for one file)
madge --warningunresolved-imports findings

To find the shortest chain of imports between two files, run fallow trace --path <from> <to>. See fallow trace.

Orphans and unused files

madge reports an orphan when no other module depends on it. Fallow reports an unused file when no entry point reaches it. The two lists are different:

  • A file that nothing imports, but that is an entry point, is a madge orphan. Fallow does not report it. Fallow finds entry points from package.json, from scripts, and from the built-in framework plugins.
  • A group of files that import each other, but that no entry point reaches, has no madge orphan. Fallow reports each file in the group as unused.

What madge does better

  • Graph image in one step. madge --image writes an SVG or a PNG directly, with configurable colors and layout. Fallow writes DOT or Mermaid text, and you render it with Graphviz or a Mermaid tool. The default fallow viz output is an interactive HTML map instead.
  • Leaves. madge --leaves lists the modules with no dependencies. Fallow has no such list.
  • Full graph as JSON. madge --json prints the full dependency tree, and --stdin reads it back. Fallow has no JSON dump of the full graph.
  • Other module formats. madge reads AMD modules, and it follows the dependencies of Sass, Stylus, and Less files. Fallow reads ES modules and CommonJS in JavaScript and TypeScript, and the imports in Vue, Svelte, Astro, MDX, and HTML files. See Non-JS file types. For styles, fallow tracks @import, @use, and @forward in CSS and SCSS. See CSS and SCSS extraction.
  • JavaScript API. madge has a promise-based Node.js API with methods such as circular() and orphans(). Fallow has Node.js bindings with a different shape.

What fallow adds

  • Unused code. Fallow reports unused exports, types, dependencies, enum members, and class members. madge does not.
  • Boundaries. Fallow checks the imports between architecture zones that you define. See Boundaries.
  • Entry points without a path argument. Fallow finds the entry points of the project, so you do not pass a source directory or a tsConfig option.
  • More analyses in one run. Fallow also reports duplication and complexity hotspots. Run fallow without a subcommand to get all analyses in one pass.
  • CI formats. Fallow writes JSON, SARIF, CodeClimate, and pull request comments. See CI integration.

Move a madge check to fallow

A typical CI step runs madge --circular and fails when it finds a cycle. To do the same with fallow, run:

fallow architecture --cycles

The command exits with code 1 when it finds a cycle, because circular-dependencies has the default severity error. See Exit codes. To adopt the check on a codebase that already has cycles, save a baseline first. See Baselines.

See also