DB Studio

Getting Started

Quick Start

No installation needed! Just run this command:

npx db-studio

This runs the latest version of DB Studio using your current folder as the project location.

How It Works

DB Studio looks for your database connection in this order:

  1. Checks for a .env file in your current folder
  2. If not found, searches parent folders until it finds one
  3. Reads DATABASE_URL from that file
  4. If DATABASE_URL isn't in the file, checks your system environment variables

Setting Up Your Database Connection

Create a .env file in your project:

# .env
DATABASE_URL=postgresql://user:password@localhost:5432/mydatabase

Then run:

npx db-studio

DB Studio will:

  1. Find and read your .env file
  2. Start a server on port 3333
  3. Open your browser to http://localhost:3333

Command Options

You can customize how DB Studio runs with these options:

OptionWhat It DoesExample
--env <path>Use a specific .env filenpx db-studio --env .env.local
--var-name <name>Use a different variable name instead of DATABASE_URLnpx db-studio --var-name MY_DB_URL
--port <number>Change the server port (default is 3333)npx db-studio --port 4000
--database-url <url>Provide connection string directly without .env filenpx db-studio --database-url "postgresql://user:pass@localhost:5432/mydb"
--statusOnly check if connection works (doesn't open the UI)npx db-studio --status
--helpShow all available optionsnpx db-studio --help

Real Examples

# Use a different env file for local development
npx db-studio --env .env.local

# Use production env file with custom port
npx db-studio --env .env.production --port 4444

# Connect directly without env file (good for quick tests)
npx db-studio --database-url "postgresql://user:pass@host:5432/prod"

# Use custom variable name with specific env file
npx db-studio --env .env.staging --var-name STAGING_DB_URL

# Just check if your connection works
npx db-studio --status

Add to Your Project

You can add DB Studio to your package.json scripts:

{
  "scripts": {
    "db:studio": "npx db-studio"
  }
}

Then run it with:

npm run db:studio

Passing Options Through npm/bun

When using npm run or bun run, add -- before your options:

# Local dev with custom env file
npm run db:studio -- --env .env.local

# Production with custom port
bun run db:studio -- --env .env.production --port 4444

# Custom variable name
npm run db:studio -- --var-name STAGING_DB_URL

Switching from Other Tools

From Prisma Studio

Replace this:

package.json
"scripts": {
  "studio": "npx prisma studio"
}

With this:

package.json
"scripts": {
  "studio": "npx db-studio"
}

DB Studio uses the same DATABASE_URL from your .env file. No extra config needed!

From Drizzle Studio

Replace this:

package.json
"scripts": {
  "studio": "npx drizzle-kit studio"
}

With this:

package.json
"scripts": {
  "studio": "npx db-studio"
}

Works the same way - just uses your existing DATABASE_URL.

On this page