A type-safe and autocompletion-friendly TypeScript SQL query builder for Node.js, Deno, Bun, and browsers.
Kysely is a type-safe SQL query builder for TypeScript that provides compile-time validation and autocompletion for database queries. It solves the problem of runtime SQL errors by ensuring that all table and column references are valid at compile time, and it accurately types query results. It supports multiple SQL dialects and runs across various JavaScript environments.
TypeScript developers building applications with relational databases who need a reliable, type-safe way to construct SQL queries without using a full ORM.
Developers choose Kysely for its robust type safety, excellent IDE autocompletion, and flexibility across SQL dialects and JavaScript runtimes, offering a lightweight alternative to ORMs with fewer runtime surprises.
A type-safe TypeScript SQL query builder
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides compile-time validation of table and column references, preventing runtime errors, as demonstrated in the README's gif and description.
Offers autocompletion for table names, columns, and aliases, boosting developer productivity, shown in the demo gif.
Works with PostgreSQL, MySQL, SQLite, Microsoft SQL Server, and more, making it versatile across different databases, as highlighted in the badges.
Runs on Node.js, Deno, Bun, Cloudflare Workers, and web browsers, supporting various JavaScript environments per the README.
Infers types from subqueries, joins, WITH statements, and aliases automatically, as emphasized in the README's features.
Unlike Knex.js, which inspired it, Kysely lacks migration tools, requiring separate solutions for schema changes.
For dynamic queries, escape hatches like the sql template tag are needed, which can bypass type safety and add complexity.
Full benefits require TypeScript, limiting its appeal for JavaScript-only projects and adding setup overhead.
Advanced type inference might challenge developers unfamiliar with TypeScript's type system, as noted in the complex features.
Kysely is an open-source alternative to the following products: