Non-existent tables, misspelled columns, mistyped values: Kysely surfaces them as you type, as agents code, and as your schema evolves, not in production at 3am.
When a column gets renamed, the TypeScript compiler walks you through every query that needs updating.
const rows = await db
.selectFrom('person')
.select('first_name')
.where('person.ag', '>', 18)
.execute()Extract any fragment of a query into a plain, typed function and reuse it across queries. Expressions, subqueries, and CTEs all compose the same way. It's just TypeScript.
Here, a correlated subquery returns each person's pets as typed, nested JSON. One query, one round trip, no relations DSL to learn.
function withPets(
eb: ExpressionBuilder<DB, 'person'>,
) {
const pets = eb
.selectFrom('pet')
.select(['name', 'species'])
.whereRef('owner_id', '=', 'person.id')
return jsonArrayFrom(pets).as('pets')
}
const person = await db
.selectFrom('person')
.select(['id', 'first_name'])
.select(withPets)
.executeTakeFirstOrThrow()What Kysely optimizes for.
Precise TypeScript result types and compile-time errors within queries. With kysely-codegen, your database is the source of types.
A thin abstraction layer over SQL, crafted by SQL lovers for SQL lovers. Familiar naming, predictable 1:1 query compilation.
Your database schema types flow through Kysely's fluent API. A typing experience second only to full-blown database IDEs.
Spec-faithful APIs for everything production teams need, composable all the way down, escape hatches everywhere.
No environment-specific APIs, nothing to bundle around. Runs in Node.js, Deno, Bun, AWS Lambda, Cloudflare Workers, and browsers.
Plugins modify queries before compilation and results after execution. camelCase to snake_case and back, for example.
Everything is documented inline, with type-checked code examples that can't drift. Hover docs for humans, rich context for agents.
PostgreSQL, MySQL, MS SQL Server, SQLite, and PGlite out of the box, plus a community-driven dialect system for everything else.
Unprompted, in public, on the record.











































































































