> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/astral-sh/uv/llms.txt
> Use this file to discover all available pages before exploring further.

# uv tree

> Display the project's dependency tree

Display the dependency tree for the project.

## Usage

```bash theme={null}
uv tree [OPTIONS]
```

## Description

Display the project's dependency tree, showing how packages depend on each other.

By default, the tree is filtered to match the current platform and Python version. Use `--universal` to display the tree for all platforms, or use `--python-version` or `--python-platform` to filter for specific environments.

## Options

### Display Options

<ParamField path="--universal" flag>
  Show a platform-independent dependency tree.

  Shows resolved package versions for all Python versions and platforms, rather than filtering to those that are relevant for the current environment.

  Multiple versions may be shown for each package.
</ParamField>

<ParamField path="--depth" type="number">
  Maximum display depth of the dependency tree.

  Short form: `-d`
</ParamField>

<ParamField path="--prune" type="string[]">
  Prune the given package from the display of the dependency tree.
</ParamField>

<ParamField path="--package" type="string[]">
  Display only the specified packages.
</ParamField>

<ParamField path="--no-dedupe" flag>
  Do not de-duplicate repeated dependencies.

  By default, uv will de-duplicate dependencies that appear multiple times in the tree.
</ParamField>

<ParamField path="--invert" flag>
  Show the reverse dependencies for the given package.

  Short form: `-i`
</ParamField>

### Dependency Selection

<ParamField path="--group" type="string[]">
  Include dependencies from the specified dependency group.

  May be provided multiple times.
</ParamField>

<ParamField path="--no-group" type="string[]">
  Disable the specified dependency group.

  This option always takes precedence over default groups, `--all-groups`, and `--group`.

  May be provided multiple times.

  Environment variable: `UV_NO_GROUP`
</ParamField>

<ParamField path="--all-groups" flag>
  Include dependencies from all dependency groups.

  `--no-group` can be used to exclude specific groups.
</ParamField>

<ParamField path="--no-default-groups" flag>
  Ignore the default dependency groups.

  uv includes the groups defined in `tool.uv.default-groups` by default. This disables that option, however, specific groups can still be included with `--group`.

  Environment variable: `UV_NO_DEFAULT_GROUPS`
</ParamField>

<ParamField path="--only-group" type="string[]">
  Only include dependencies from the specified dependency group.

  The project and its dependencies will be omitted.

  May be provided multiple times. Implies `--no-default-groups`.
</ParamField>

<ParamField path="--only-dev" flag>
  Only include the development dependency group.

  The project and its dependencies will be omitted.

  This option is an alias for `--only-group dev`. Implies `--no-default-groups`.
</ParamField>

### Locking Options

<ParamField path="--locked" flag>
  Assert that the `uv.lock` will remain unchanged.

  Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated, uv will exit with an error.

  Environment variable: `UV_LOCKED`
</ParamField>

<ParamField path="--frozen" flag>
  Display the requirements without locking the project.

  If the lockfile is missing, uv will exit with an error.

  Environment variable: `UV_FROZEN`
</ParamField>

### Script Options

<ParamField path="--script" type="path">
  Show the dependency tree for the specified PEP 723 Python script, rather than the current project.

  If provided, uv will resolve the dependencies based on its inline metadata table, in adherence with PEP 723.
</ParamField>

### Python Options

<ParamField path="--python" type="string">
  The Python interpreter to use for locking and filtering.

  By default, the tree is filtered to match the platform as reported by the Python interpreter. Use `--universal` to display the tree for all platforms, or use `--python-version` or `--python-platform` to override a subset of markers.

  See `uv help python` for details on Python discovery and supported request formats.

  Short form: `-p`\
  Environment variable: `UV_PYTHON`
</ParamField>

<ParamField path="--python-version" type="string">
  The Python version to use when filtering the tree.

  For example, pass `--python-version 3.10` to display the dependencies that would be included when installing on Python 3.10.

  Defaults to the version of the discovered Python interpreter.
</ParamField>

<ParamField path="--python-platform" type="string">
  The platform to use when filtering the tree.

  For example, pass `--platform windows` to display the dependencies that would be included when installing on Windows.

  Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or `aarch64-apple-darwin`.
</ParamField>

## Examples

### Display basic dependency tree

```bash theme={null}
uv tree
```

Shows the dependency tree for the current project.

### Show universal tree

```bash theme={null}
uv tree --universal
```

Displays dependencies for all platforms and Python versions.

### Limit tree depth

```bash theme={null}
uv tree --depth 2
```

Shows only the first two levels of dependencies.

### Show reverse dependencies

```bash theme={null}
uv tree --invert requests
```

Shows which packages depend on `requests`.

### Prune packages from display

```bash theme={null}
uv tree --prune pytest --prune mypy
```

Hides `pytest` and `mypy` from the tree (but shows their dependencies).

### Show specific packages

```bash theme={null}
uv tree --package requests --package urllib3
```

Displays only the subtrees for `requests` and `urllib3`.

### Show without deduplication

```bash theme={null}
uv tree --no-dedupe
```

Shows all instances of dependencies, even if they appear multiple times.

### Filter by Python version

```bash theme={null}
uv tree --python-version 3.10
```

Shows dependencies as they would be resolved for Python 3.10.

### Filter by platform

```bash theme={null}
uv tree --python-platform linux
```

Shows dependencies for Linux.

### Show tree for a script

```bash theme={null}
uv tree --script my_script.py
```

Displays the dependency tree for a PEP 723 script.

### Show only dev dependencies

```bash theme={null}
uv tree --only-dev
```

### Include specific dependency groups

```bash theme={null}
uv tree --group test --group docs
```

## Common Patterns

### Debugging dependency conflicts

```bash theme={null}
# See full tree without deduplication
uv tree --no-dedupe

# Find what depends on a specific package
uv tree --invert problematic-package
```

### Checking cross-platform dependencies

```bash theme={null}
# Check Linux dependencies
uv tree --python-platform x86_64-unknown-linux-gnu

# Check macOS dependencies  
uv tree --python-platform aarch64-apple-darwin

# Check Windows dependencies
uv tree --python-platform x86_64-pc-windows-msvc
```

### Understanding dependency depth

```bash theme={null}
# See immediate dependencies only
uv tree --depth 1

# See two levels
uv tree --depth 2
```

### Analyzing specific packages

```bash theme={null}
# Show only web-related dependencies
uv tree --package fastapi --package uvicorn --package pydantic

# Hide test dependencies from view
uv tree --prune pytest --prune hypothesis
```

### CI/CD verification

```bash theme={null}
# Ensure tree matches expectations
uv tree --frozen
```

## Output Format

The tree output shows package dependencies in a hierarchical format:

```
my-project v0.1.0
├── requests v2.31.0
│   ├── charset-normalizer v3.3.2
│   ├── idna v3.6
│   ├── urllib3 v2.1.0
│   └── certifi v2023.11.17
└── rich v13.7.0
    ├── markdown-it-py v3.0.0
    │   └── mdurl v0.1.2
    └── pygments v2.17.2
```

When using `--invert`, the tree is reversed to show dependents:

```
requests v2.31.0
└── my-project v0.1.0
```

## Related Commands

* [`uv lock`](/cli/lock) - Update the lockfile
* [`uv sync`](/cli/sync) - Sync the environment
* [`uv add`](/cli/add) - Add dependencies
* [`uv remove`](/cli/remove) - Remove dependencies
