
Kysely
Type-safe TypeScript SQL query builder for Postgres, MySQL and SQLite, with types inferred from your database schema.
Works with AI agents:llms.txtKysely is a TypeScript library for building SQL queries with full type checking. It is not an ORM: you think in tables and joins, but the compiler knows which tables and columns are in scope at each point of a query and what shape the result rows will have.
The model is small. You give the Kysely constructor a TypeScript interface describing your database's tables, plus a dialect, the adapter for one database engine. Built-in dialects cover PostgreSQL, MySQL, SQL Server, SQLite and PGlite, and community dialects add Postgres.js, serverless drivers for PlanetScale and TiDB, Cloudflare Durable Objects and others. Queries are chained method calls that compile to SQL. Kysely infers columns and aliases even through subqueries and CTEs; a sql template tag covers the rest.
What you get: transactions, including controlled ones with savepoints; helpers such as jsonArrayFrom that fetch nested objects and arrays in a single query; a plugin system that hooks into query compilation and results; and a built-in migrator that runs ordered up and down functions. It is mainly developed for Node.js but also runs on Deno, Bun and in browsers, where it can compile SQL without a connection.
Limits: Kysely has no relations or models, so no automatic eager loading or change tracking. It does not create your schema types for you either; you write them by hand or generate them with third-party tools such as kysely-codegen or prisma-kysely. Migrations are code you write, not diffs generated from a schema.
Where it fits
How Kysely itself is built
1 tools, from its own code, website and Product Hunt page.
Who uses it
No maker's live product on record yet, and 39 open-source projects that declare it in their code.
We haven't found a maker's live product that uses Kysely yet — only the open-source projects below, which declare it in their code.
Open source: a project that declares Kysely as a dependency in its public code — verifiable, but not necessarily a live product.
Loved and watch-outs
Themes that recur in makers' words and Hacker News comments, each linked to what it summarises.
- It is a thin, SQL-shaped query builder with unusually strong TypeScript typing, so you keep writing SQL without hiding it behind an ORM. HNHN 2HN 3HN 4
- Queries compose well, which handles dynamic filters and even serves as the engine for other ORMs. HNHN 2HN 3
- It sits alongside Prisma or plain SQL schemas for performance-critical queries and SQL features an ORM does not support. HNHN 2HN 3HN 4
- Teams moving off heavier ORMs like TypeORM saw big gains in query speed and memory use. HNHN 2
- Not being an ORM, it does not generate migrations or offer declarative schemas, and rows still need mapping into objects. HNHN 2HN 3
- Complex queries are harder to translate into builder calls than to write in SQL directly. HNHN 2
- Support varies by dialect; the ClickHouse extension is immature and features like savepoints depend on the dialect. HNHN 2
Reliability and open issues
- You're awesome! Thank you 🙏🏽👍 24 · opened Dec 2025 · active Dec 2025
- add Snowflake dialect.👍 23 · opened Jan 2026 · active May 2026
- Suggestion: Allow Execution driver to execute multiple queries👍 22 · opened Mar 2024 · active Dec 2025
- Add a way to stream raw query results.👍 15 · opened Mar 2025 · active Nov 2025
- [Feature] Allow window function modification👍 11 · opened May 2023 · active Jan 2026
Who switches
Public pull requests on GitHub since Oct 2024 whose title says "X to Y" — real code changes moving a project from one tool to another, by developers in general. Open a row to see the pull requests.
Prisma → Kysely10 PRs
- refactor(db): Phase 3 — migrate Prisma master-table repositories to Kysely (#62)flipslidersand-labs/loopnest-core · 2026-09-06
- fix: three bugs found while scoping the Prisma to Kysely migrationcivitai/civitai · 2026-08-09
- Migrate excavator-web from Prisma to Kysely to fix runaway memory usageloathers/excavator · 2026-07-24
- Migrate database layer from Prisma to Kyselyloathers/museum · 2026-05-10
- Migrate from Prisma to Kyselyloathers/greenbox · 2026-05-10
- Migrate from prisma to kysely because prisma has become annoyingloathers/oaf · 2026-02-13
- Migration from Prisma ORM to Kysely queries + update Zod from v3 to v4introbotai/linkedin-resolver · 2025-12-26
- feat: migrate from Prisma to Kysely for better performanceruidolp/wapp · 2025-11-06
- Migrate from prisma to kyselylpgera/cookbook · 2025-11-02
- feat: Switch from Prisma to Kysely for the meantimeredwoodjs/sdk · 2024-11-26
Drizzle ORM → Kysely5 PRs
- migration: drizzle to kysely, slim down to data APIdvgamerr-app/aide-collector · 2026-06-17
- refactor(db): switch from drizzle to kysely + atlasponti-studios/hominem · 2026-03-07
- feat: migrate hono example from Drizzle to KyselyAndrey-jpeg/goodie · 2026-03-01
- feat: migrate hono example and docs from Drizzle to KyselyAndrey-jpeg/goodie · 2026-03-01
- refactor!: change drizzle to kysely for internal querieswannabespace/conar · 2025-11-14
Kysely → Drizzle ORM6 PRs
- refactor(api): switch from Kysely and dbmate to Drizzle ORM and drizzle-kityutaasakura96/overload · 2026-09-25
- Add SQL to Kysely generator and upgrade SQL to Drizzle tooldaxt61/multi-tool-site · 2026-09-23
- refactor(db): migrate from kysely to drizzleblinkdisk/blinkdisk · 2026-06-28
- Migrate Playwright tests from Kysely to Drizzle ORM and add CI workflowncrmro/website · 2025-12-24
- Migrate from Kysely to Drizzle ORMncrmro/website · 2025-11-20
- Migrated from Kysely to Drizzle and implemented a Demo modeRaulRohjans/spenser · 2025-08-18
Alternatives to Kysely
All alternatives by situation →Questions makers ask about Kysely
Which databases does Kysely support?
Built-in dialects cover PostgreSQL, MySQL, Microsoft SQL Server, SQLite and PGlite. Community dialects add Postgres.js, SingleStore, the PlanetScale and TiDB serverless drivers, Cloudflare Durable Objects, AWS RDS Data API, ClickHouse and more. source ↗
Do I have to write the database types by hand?
You can, but Kysely recommends generating them for production apps with third-party tools; kysely-codegen introspects a live database, prisma-kysely reads an existing Prisma schema, and kanel-kysely covers PostgreSQL. source ↗
Can I load related rows like an ORM?
Kysely has no relations, but helpers such as jsonArrayFrom and jsonObjectFrom fetch nested arrays and objects in one query. They may not work with third-party dialects that return JSON as strings. source ↗
How do migrations work?
Each migration exports up and down functions that receive a Kysely instance and run in alphanumeric order of their names; Kysely errors if a new migration sorts before already-run ones unless you enable allowUnorderedMigrations. Migrations should not import your app code, so they stay fixed in time. source ↗
Does it run outside Node.js?
Yes. Kysely is mainly developed for Node.js but also runs on Deno, Bun and other JavaScript environments, and in browsers it can compile queries without a database connection. source ↗
What if the query builder cannot express my query?
Use the sql template tag to write raw SQL fragments, which can be mixed into builder queries, as an escape hatch for cases that cannot be typed at compile time. source ↗
Is Kysely free?
Yes — it is free, open-source software.
Is Kysely open source or self-hostable?
Open source, and you can self-host it. source ↗
Can AI coding agents work with Kysely?
It serves an llms.txt docs index.
Who uses Kysely?
No maker's live product we track yet; 39 open-source projects declare it in their code. source ↗