Kysely
Type-safe SQL query builder for TypeScript that provides composable, dialect-aware query construction without ORM abstractions, supporting PostgreSQL, MySQL, SQLite, and community dialects.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
All builder-generated queries use parameterized values preventing SQL injection; sql template tag requires manual care; minimal dependency footprint reduces supply chain risk
⚡ Reliability
Best When
Writing data-access code in TypeScript where full SQL expressiveness is required alongside compile-time column and type safety without the overhead of a full ORM.
Avoid When
The project needs an integrated migration runner, schema-first code generation, or relation-level eager loading built into the query layer.
Use Cases
- • Build complex dynamic SQL queries with full TypeScript type inference on table columns and join results
- • Compose reusable query fragments (subqueries, CTEs, conditional where clauses) in a type-safe way across a large codebase
- • Use as the query layer in a custom data-access architecture where ORM conventions are unwanted
- • Migrate from Knex.js to a type-safe alternative with near-identical query builder ergonomics
- • Integrate with edge runtimes via community dialects (Cloudflare D1, PlanetScale, Neon) without a large binary dependency
Not For
- • Projects that need automatic migrations, schema management, or an ORM-level relations API out of the box
- • Teams unfamiliar with SQL who want high-level active-record-style finders generated from a schema definition
- • Applications targeting databases beyond SQL (e.g., MongoDB, Redis) which Kysely does not support
Interface
Authentication
Library with no network auth layer; credentials are passed to the underlying driver (pg, mysql2, better-sqlite3) during Kysely instantiation
Pricing
Completely free and open source with no commercial tier
Agent Metadata
Known Gotchas
- ⚠ Kysely is pre-1.0 and makes occasional breaking API changes; pin exact versions in agent-managed projects
- ⚠ No built-in migration system — agents must pair Kysely with a separate migration tool like kysely-migrate or raw SQL files
- ⚠ Type inference depends on a Database interface that must be kept manually in sync with the actual schema
- ⚠ sql template tag bypasses type checking and can silently produce invalid SQL if used carelessly
- ⚠ Community dialects (D1, Neon, PlanetScale) vary in maturity and may not support all Kysely features
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for Kysely.
Scores are editorial opinions as of 2026-03-06.