Drizzle ORM

A lightweight, zero-dependency TypeScript ORM with full SQL-like query flexibility

Library
npm
v0.45.3
35,907 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
79 /100 Good
Development Activity 76
Maintenance 76
Community 64
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
81 /100 Excellent
Architecture 90
Code Quality 82
Innovation 85
Learning Curve 68

Drizzle ORM is a TypeScript-first ORM and SQL query builder built around the idea that you should never have to leave SQL-like syntax to get type safety. It ships as a headless, ~7.4kb library with zero runtime dependencies, and supports PostgreSQL, MySQL, SQLite, and SingleStore across every major JavaScript runtime, including Node.js, Bun, Deno, Cloudflare Workers, and edge functions.

Rather than hiding the database behind a heavyweight abstraction, Drizzle lets you declare schemas in TypeScript and then either write relational queries (similar to an ORM) or SQL-like queries (similar to a query builder), both fully typed end to end. Its companion CLI, Drizzle Kit, handles migrations, and Drizzle Studio provides a GUI for browsing and editing data, giving teams a complete, serverless-ready toolkit without generated clients or Rust binaries.

What You Get

  • A ~7.4kb, zero-runtime-dependency core library that stays tree-shakeable and works in serverless/edge runtimes
  • Type-safe schema declarations that double as the source of truth for both migrations and query type inference
  • Two query APIs in one library: a chained SQL-style builder and a relational-query API (db.query.table.findMany())
  • Drizzle Kit, a companion CLI for generating and applying SQL migrations from your TypeScript schema
  • Drizzle Studio, a GUI for browsing and editing data across any supported database
  • First-class drivers for PostgreSQL, MySQL, SQLite, and SingleStore, plus serverless-specific adapters for Neon, Turso, PlanetScale, Cloudflare D1, and Vercel Postgres

Common Use Cases

  • Adding a typed data layer to a Next.js, Remix, or SvelteKit app without a code-generation build step
  • Running database access from edge/serverless functions (Cloudflare Workers, Vercel Edge) where lightweight, dependency-free clients matter
  • Migrating off a heavier ORM (Prisma, TypeORM) when teams want SQL-like control with full TypeScript inference
  • Building internal tools or admin panels quickly using Drizzle Studio alongside the schema already defined for the app

Under The Hood

Architecture — drizzle-orm/src/index.ts re-exports the dialect-agnostic core: column/table builders (column-builder.ts, column.ts, table.ts), the branded-type system (entity.ts), and the SQL AST builder (sql/sql.ts, 722 lines). Each dialect (pg-core/, mysql-core/, sqlite-core/, singlestore-core/, gel-core/) implements its own column types and query builders on top of that shared AST — for example pg-core/query-builders/select.ts (1,346 lines) builds a Query object that is rendered through a BuildQueryConfig interface (escapeName/escapeParam/escapeString), which is how one query-builder API targets many SQL dialects. Driver adapters (node-postgres/, postgres-js/, neon-http/, libsql/, better-sqlite3/, bun-sqlite/, d1/, planetscale-serverless/, mysql2/, and more) each wrap one database client and adapt it to a common Session/QueryPromise interface (session.ts, query-promise.ts). Because the library is split across dozens of separately-published driver packages, instanceof checks are unreliable across module boundaries, so the codebase uses a symbol-based entityKind brand and an is() helper (entity.ts) pervasively instead.

Tech Stack — Pure TypeScript, published as dual ESM/CJS via a custom scripts/build.ts. The core drizzle-orm package declares zero runtime dependencies in package.json — all 29 database drivers and clients (pg, mysql2, better-sqlite3, @neondatabase/serverless, @libsql/client, and others) are optional peerDependencies, so consumers only install what they actually use. The repository is a pnpm + Turborepo monorepo (pnpm-workspace.yaml, turbo.json) housing sibling packages drizzle-kit (migrations CLI), drizzle-zod/drizzle-valibot/drizzle-arktype/drizzle-typebox (schema-validation bridges), and drizzle-seed. It targets every major JavaScript runtime — Node.js, Bun, Deno, Cloudflare Workers/D1, Vercel Edge, and React Native via op-sqlite/expo-sqlite adapters.

Code Quality — There are no unit test files co-located in drizzle-orm/src/, but the root-level integration-tests/ workspace contains 68 test files (run via Vitest against real database connections per dialect) plus a separate type-tests/ directory that performs compile-time type assertions to catch inferred query-type regressions — a pattern suited to a library whose main product is precise type inference. Error handling is centralized through a DrizzleError/DrizzleQueryError hierarchy (errors.ts) that preserves the original driver error on .cause. Naming and file layout are strikingly consistent across dialect implementations — pg-core/, mysql-core/, and sqlite-core/ mirror each other’s structure almost exactly, which keeps the cost of adding a new dialect low and the codebase easy to navigate once one dialect is understood.

API Design — A single call, drizzle(client, { schema }), returns a fully-typed db object usable immediately for both SQL-style chained queries (db.select().from(table).where(...)) and relational-style queries (db.query.table.findMany()), with no separate code-generation step — the TypeScript schema declaration is itself the source of type inference. A minimal schema.ts using pgTable(...)/sqliteTable(...) is enough to get full autocomplete on selects, inserts, joins, and relations. The trade-off is setup complexity: the 29-entry peerDependencies list means a new user has to correctly match a driver package to their database and runtime before anything works, and the per-driver README files scattered through src/ (postgres-js/README.md, kysely/README.md, etc.) reflect how much dialect/driver-specific knowledge the API surface still requires.

Used by 118 apps in this directory

TypeScript
75%
MIT

OpenCode

AI Code Assistants

210,460

A fully open-source AI coding agent built for the terminal, with a TUI, desktop app, web client, plugin system, and SDK — one of the most-starred AI coding agents on GitHub.

View details
89
Repo Health
76
Technical
67
Dependency
Built with
TypeScript 75%
MDX 22%
Updated 1 weeks ago
TypeScript
94%
Apache 2.0

Openship

Devops · Hosting Control Panel

12,979

Openship is an open-source, self-hostable deployment platform that points at a repo and builds, ships, routes, and TLS-terminates the app — driven from a desktop app, web dashboard, or CLI.

View details
84
Repo Health
85
Technical
65
Dependency
Built with
TypeScript 94%
Updated 1 weeks ago
TypeScript
94%
Apache 2.0

Openship

Devops · Hosting Control Panel

12,979

Openship is an open-source, self-hostable deployment platform that points at a repo and builds, ships, routes, and TLS-terminates the app — driven from a desktop app, web dashboard, or CLI.

View details
84
Repo Health
85
Technical
65
Dependency
Built with
TypeScript 94%
Updated 1 weeks ago
TypeScript
90%
MIT

openwork

AI Assistants · Automation

23,765

OpenWork is a free, open-source desktop app for running AI agent workflows on your own files with 50+ LLMs, extensible skills, and MCP server support — the open-source alternative to Claude Cowork and Codex.

View details
87
Repo Health
89
Technical
67
Dependency
Built with
TypeScript 90%
Updated 1 weeks ago
TypeScript
90%
MIT

openwork

AI Assistants · Automation

23,765

OpenWork is a free, open-source desktop app for running AI agent workflows on your own files with 50+ LLMs, extensible skills, and MCP server support — the open-source alternative to Claude Cowork and Codex.

View details
87
Repo Health
89
Technical
67
Dependency
Built with
TypeScript 90%
Updated 1 weeks ago
TypeScript
55%
MIT

optio

AI Agents · AI Code Assistants

1,054

Self-hosted AI agent workflow orchestration that runs on your Kubernetes cluster — from ticket intake to squash-merged PR, entirely within your infrastructure.

View details
80
Repo Health
81
Technical
70
Dependency
Built with
TypeScript 55%
Kotlin 32%
Swift 12%
Updated 1 weeks ago
TypeScript
55%
MIT

optio

AI Agents · AI Code Assistants

1,054

Self-hosted AI agent workflow orchestration that runs on your Kubernetes cluster — from ticket intake to squash-merged PR, entirely within your infrastructure.

View details
80
Repo Health
81
Technical
70
Dependency
Built with
TypeScript 55%
Kotlin 32%
Swift 12%
Updated 1 weeks ago
TypeScript
99%
AGPL 3.0

Pangolin

Networking

22,937

An open-source, identity-based zero-trust remote access platform built on WireGuard — a self-hostable alternative to Cloudflare Tunnel and Twingate with SSO, OIDC, and tunneled reverse proxying.

View details
87
Repo Health
68
Technical
68
Dependency
Built with
TypeScript 99%
Updated 1 weeks ago
TypeScript
99%
AGPL 3.0

Pangolin

Networking

22,937

An open-source, identity-based zero-trust remote access platform built on WireGuard — a self-hostable alternative to Cloudflare Tunnel and Twingate with SSO, OIDC, and tunneled reverse proxying.

View details
87
Repo Health
68
Technical
68
Dependency
Built with
TypeScript 99%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers