# db schema (/docs/cli/db-schema)

> For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL.

Inspect a live database schema.

Location: CLI > db schema

`db schema` reads the live database schema and prints it as a tree, or as the result document with `--json`. The command is always read-only: it never writes a file and never changes the database.

Use it when you need to inspect what Prisma 8 sees in the database before inferring, signing, updating, or debugging drift.

## Usage [#usage]

  

#### bun

```bash
bunx prisma@latest db schema --db "$DATABASE_URL"
```

#### pnpm

```bash
pnpm dlx prisma@latest db schema --db "$DATABASE_URL"
```

#### yarn

```bash
yarn dlx prisma@latest db schema --db "$DATABASE_URL"
```

#### npm

```bash
npx prisma@latest db schema --db "$DATABASE_URL"
```

## Options [#options]

| Option            | What it does                                           |
| ----------------- | ------------------------------------------------------ |
| `--db <url>`      | Connects to the database.                              |
| `--config <path>` | Read this config file instead of `./prisma.config.ts`. |
| `--json`          | Prints machine-readable schema output.                 |

## Examples [#examples]

  

#### bun

```bash
bunx prisma@latest db schema --db "$DATABASE_URL"
bunx prisma@latest db schema --db "$DATABASE_URL" --json > schema.json
```

#### pnpm

```bash
pnpm dlx prisma@latest db schema --db "$DATABASE_URL"
pnpm dlx prisma@latest db schema --db "$DATABASE_URL" --json > schema.json
```

#### yarn

```bash
yarn dlx prisma@latest db schema --db "$DATABASE_URL"
yarn dlx prisma@latest db schema --db "$DATABASE_URL" --json > schema.json
```

#### npm

```bash
npx prisma@latest db schema --db "$DATABASE_URL"
npx prisma@latest db schema --db "$DATABASE_URL" --json > schema.json
```

## Related commands [#related-commands]

Use [`contract infer`](https://www.prisma.io/docs/cli/contract-infer) when you want to turn a live schema into a starter PSL contract. Use [`db verify`](https://www.prisma.io/docs/cli/db-verify) when you want to compare the live schema with the emitted contract.

## Related pages

- [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions.
- [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project.
- [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets.
- [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma 8 CLI commands with prisma.config.ts and global flags.
- [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma 8 contract artifacts.