kysely

A type-safe TypeScript SQL query builder

What is kysely?

A type-safe TypeScript SQL query builder

Overview of kysely

What it is

Kysely (pronounced “Key-Seh-Lee”) is a type-safe and autocompletion-friendly TypeScript SQL query builder. Inspired by Knex.js, it is mainly developed for Node.js but also runs on Deno, Bun, Cloudflare Workers, and web browsers. Kysely ensures that you only refer to tables and columns that are visible to the part of the query you are writing, and the result type only has the selected columns with correct types and aliases.

Key features

  • Type-safe SQL query building with full TypeScript autocompletion.
  • Automatically infers column names, aliases, and types from selected subqueries, joined subqueries, with statements, and other constructs.
  • Provides escape hatches (e.g., sql template tag and DynamicModule) for cases where types cannot be determined at compile time.
  • All API documentation is written in the typing files and accessible via IDE hover.
  • Supports multiple JavaScript environments: Node.js, Deno, Bun, Cloudflare Workers, and browsers.

Use cases

  • Building complex SQL queries with compile-time type safety in TypeScript projects.
  • Replacing raw SQL strings or less type-safe query builders in Node.js, Deno, or Bun applications.
  • Running database queries in serverless environments like Cloudflare Workers.
  • Developing applications that require precise control over SQL while benefiting from TypeScript’s type system.

Getting started

See the repository README for installation and quick-start commands.

License and pricing

Licensed under the MIT License. The project is open source and free to use.

Based on the project's public README and repository metadata.

Add this badge to your README

Featured on YunoDB Badge styles & help

Maintain this project? Show that it is featured on YunoDB.

Markdown[![Featured on YunoDB](https://yunodb.com/badge/kysely-orgkysely.svg)](https://yunodb.com/tools/kysely-orgkysely?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/kysely-orgkysely?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/kysely-orgkysely.svg" alt="Featured on YunoDB" height="20"></a>