Type-safe SQL query builder

Kysely

An open-source TypeScript SQL query builder that infers table, column, alias, and result types while retaining SQL-shaped control.

Editorial verdict

Choose Kysely when the team wants compile-time query and result typing while keeping SQL structure and database behavior visible. Prefer an integrated ORM when generated models, relation workflows, or schema ownership would remove more work.1

Best for

  • TypeScript teams that already understand SQL and want static query typing
  • Applications that want a small abstraction surface with explicit dialect adapters
  • Teams prepared to own database types, migrations, and database-specific SQL
12

Not ideal for

  • Teams expecting object relation mapping, entity lifecycle, or repository patterns
  • Projects that want one framework to own schema, migrations, generated client, and data UI
  • Teams unwilling to maintain accurate database type definitions or generation tooling
1
Main trade-off

Kysely preserves SQL-shaped control and a small abstraction, but provides less model, relation, schema, and workflow machinery, leaving more consistency and migration responsibility with the application.12

Product boundary

Whether a thin compile-time typed SQL builder is sufficient without adopting a broader ORM model and schema workflow.

Kysely is a query builder with dialect and migration APIs. It is not a database, hosted service, entity mapper, schema source of truth, or complete application data platform.12

For: TypeScript teams that want typed SQL composition and are willing to own schema types, migrations, dialects, and database behavior

  • The team needs generated entity or relation APIs rather than SQL composition.
  • Maintaining database type definitions becomes a larger burden than the query builder saves.
  • The required runtime lacks a suitable Kysely dialect.
  • The organization needs a more opinionated schema and migration workflow.

Why teams consider Kysely

  • Compile-time SQL typingKysely infers tables, columns, aliases, selected fields, and query result types.12
  • Escape hatchesThe SQL template and dynamic module support cases that cannot be fully represented at compile time.12
  • Migration primitivesKysely supplies migration APIs and documents frozen-in-time up and down migration files.12

Pricing

Kysely is open-source under the MIT license with no separate software license fee. Database, dialect driver, type generation, migration execution, hosting, and engineering costs remain with the application.3

Library adoption

Open-source Kysely

No separate query-builder software license fee; all database and operating costs are external to the library.3

License
MIT3
Primary cost
Database, drivers, type generation, migrations, and engineering ownership3
Pricing checked View official pricing

Kysely vs alternatives

Drizzle ORM

Choose when
Choose it when TypeScript schema definitions and an ORM plus migration toolkit are desirable while staying SQL-like.
Compared with Kysely
The application adopts more schema and ORM surface.4

Prisma ORM

Choose when
Choose it when a generated client and integrated declarative schema workflow are more valuable than a thin builder.
Compared with Kysely
The application accepts Prisma's generated and connector boundaries.5

TypeORM

Choose when
Choose it when entity mapping and repository or Active Record conventions fit the domain and team.
Compared with Kysely
The application accepts a broader runtime ORM abstraction.6

Resources and sources

Official product, policy, and pricing

  • Kysely introduction
    Open
  • Kysely migrations
    Open
  • Kysely MIT license
    Open
  1. 1
    Kysely introduction

    Kysely · Accessed Official

  2. 2
    Kysely migrations

    Kysely · Accessed Official

  3. 3
    Kysely MIT license

    Kysely · Accessed Official

  4. 4
    Drizzle ORM overview

    Drizzle Team · Accessed Official

  5. 5
    Prisma ORM overview

    Prisma · Accessed Official

  6. 6
    TypeORM getting started

    TypeORM · Accessed Official