Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nrwl/nx/llms.txt

Use this file to discover all available pages before exploring further.

nx graph [options]
Alias: nx dep-graph nx graph opens an interactive visualization of your workspace’s project dependency graph in the browser. You can also export the graph as JSON or HTML, filter by project, or show only affected projects.

Options

Output

--file
string
Write the graph to a file instead of opening the browser. Supports .json for raw data and .html for a self-contained interactive page.
nx graph --file=output.json
nx graph --file=dep-graph.html
--print
boolean
Print the project graph to stdout in the terminal instead of opening the browser.

View mode

--view
string
default:"projects"
Choose whether to visualize the project graph or the task graph. Choices: projects, tasks.
--targets
string
The targets to show when viewing the task graph (--view=tasks). Accepts comma-separated values.
nx graph --view=tasks --targets=build,test

Filtering

--focus
string
Highlight a single project and all of its ancestors and descendants. All other projects are dimmed.
nx graph --focus=myapp
--exclude
string
Comma-separated list of projects to hide from the graph.
nx graph --exclude=e2e-app,temp-lib
--affected
boolean
Highlight only the projects that are affected by recent changes. Requires git context (uses the same base/head logic as nx affected).
--base
string
Base git ref for computing affected projects. Implies --affected.
--head
string
Head git ref for computing affected projects. Implies --affected.
--files
string
Treat specific files as changed when computing affected projects. Implies --affected.
--uncommitted
boolean
Include uncommitted changes when computing affected projects. Implies --affected.
--untracked
boolean
Include untracked files when computing affected projects. Implies --affected.

Display

--group-by-folder
boolean
Group projects visually by their folder path in the interactive graph.
--watch
boolean
default:"true"
Watch for workspace changes and automatically update the graph in the browser.
--open
boolean
default:"true"
Open the graph in the default browser. Set to false to start the server without opening.

Server

--host
string
IP address to bind the graph server to. Defaults to localhost.
--port
number
Port to bind the graph server to.
--verbose
boolean
Print additional information about the command.

Examples

nx graph
The nx affected:graph command is a deprecated alias for nx graph --affected. Use nx graph --affected instead.

Using the interactive graph

When the graph opens in the browser, you can:
  • Click a project node to see its dependencies and dependents
  • Use the sidebar to search for and filter projects
  • Toggle between Projects and Tasks views
  • Enable Group by folder to organize nodes by directory structure
  • Use Focus to isolate a project’s subgraph
  • Export the current view as a PNG or JSON