Skip to main content

Headless TypeScript ORM

Build type-safe SQL queries with zero dependencies. Drizzle ORM is lightweight, performant, and works everywhere.

~7.4kb
Minified + gzipped
Zero
Dependencies
100%
Type-safe

Quick start

Get up and running with Drizzle ORM in minutes

1

Install Drizzle ORM

Install Drizzle ORM and your database driver using your preferred package manager.
npm install drizzle-orm
npm install -D drizzle-kit
2

Define your schema

Create a schema file and define your database tables with full TypeScript support.
schema.ts
import { pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';

export const users = pgTable('users', {
  id: serial('id').primaryKey(),
  email: text('email').notNull().unique(),
  name: text('name').notNull(),
  createdAt: timestamp('created_at').defaultNow(),
});
3

Connect and query

Initialize your database connection and start querying with type-safe operations.
index.ts
import { drizzle } from 'drizzle-orm/node-postgres';
import { users } from './schema';

const db = drizzle(process.env.DATABASE_URL!);

// Type-safe insert
await db.insert(users).values({
  email: '[email protected]',
  name: 'John Doe',
});

// Type-safe select
const allUsers = await db.select().from(users);
Your queries are fully typed based on your schema definition. IDEs will provide autocomplete and type checking.

Explore by database

Drizzle ORM supports all major SQL databases with native drivers

PostgreSQL

Full support for PostgreSQL with native types, schemas, and advanced features.

MySQL

Complete MySQL and MariaDB support with all column types and constraints.

SQLite

Lightweight SQLite support for edge, mobile, and embedded databases.

Core features

Everything you need to build modern database applications

Type-safe queries

Write SQL queries with full TypeScript inference and compile-time validation.

Schema definition

Define your database schema in TypeScript with intuitive builder syntax.

Migrations

Generate and run migrations automatically with Drizzle Kit.

Relations

Define and query table relationships with type-safe join operations.

Transactions

Execute multiple queries atomically with full ACID guarantees.

Prepared statements

Optimize performance with reusable prepared statements.

Ecosystem tools

Powerful tools to enhance your development workflow

Drizzle Kit

CLI companion for schema migrations, introspection, and database management.

Drizzle Studio

Visual database browser to explore and manipulate your data effortlessly.

Drizzle Seed

Generate realistic test data and seed your database for development.

Schema validation

Integrate with Zod, Valibot, TypeBox, and ArkType for runtime validation.

Ready to get started?

Join thousands of developers building type-safe database applications with Drizzle ORM

Start Building

Build docs developers (and LLMs) love