---
title: task-graph
---

import VersionLabel from '@site/src/components/Docs/VersionLabel';

<VersionLabel version="1.30.0" header />

The `moon task-graph [target]` (or `moon tg`) command will generate and serve a visual graph of all
configured tasks as nodes, with dependencies between as edges, and can also output the graph in
[Graphviz DOT format](https://graphviz.org/doc/info/lang.html).

```shell
# Run the visualizer locally
$ moon task-graph

# Export to DOT format
$ moon task-graph --dot > graph.dot
```

> A task target can be passed to focus the graph to only that task and its dependencies. For
> example, `moon task-graph app:build`.

### Arguments

- `[target]` - Optional target of task to focus.

### Options

- `--dependents` - Include direct dependents of the focused task.
- `--dot` - Print the graph in DOT format.
- `--host` - The host address. Defaults to `127.0.0.1`. <VersionLabel version="1.36.0" />
- `--json` - Print the graph in JSON format.
- `--port` - The port to bind to. Defaults to a random port. <VersionLabel version="1.36.0" />

## Example output

The following output is an example of the graph in DOT format.

```dot
digraph {
    0 [ label="types:build" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
    1 [ label="runtime:build" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
    2 [ label="website:build" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
    1 -> 0 [ label="required" arrowhead=box, arrowtail=box]
    2 -> 1 [ label="required" arrowhead=box, arrowtail=box]
    2 -> 0 [ label="required" arrowhead=box, arrowtail=box]
}
```
