kysely is a free, open source browsers & extensions project written in TypeScript and released under MIT. It has 14,233 GitHub stars, 444 forks and 173 open issues, and was last pushed 10 hours ago. On this registry it ranks #29 of 65 tracked projects in Browsers & Extensions, with 5 head-to-head comparisons available. It gained 7 stars over the last 3 tracked days.

What is kysely?

What it is

Kysely is a type-safe TypeScript SQL query builder for Node.js, Deno, Bun, and the browser. It provides a fluent API to construct and execute type-safe SQL queries, preventing runtime errors from invalid column names or incorrect data types. The core problem it solves is eliminating the fragility of raw SQL strings and the lack of type safety in many ORMs within the TypeScript ecosystem.

The library operates across the full JavaScript runtime landscape and integrates directly with multiple SQL database drivers. Its design focuses on providing compile-time guarantees for query correctness, which streamlines development and reduces debugging time for data access layers.

Key capabilities

  • Provides full autocompletion and type checking for SQL keywords, table names, and columns.
  • Supports PostgreSQL, MySQL, Microsoft SQL Server, and SQLite databases.
  • Works in Node.js, Deno, Bun, and browser environments.
  • Offers a composable and chainable API for building complex SQL queries.
  • Includes type-safe query builders for filtering, selecting, joining, and inserting data.
  • Features a migration system for version controlling database schemas.

Who uses it and how

  • Backend developers in TypeScript projects build type-safe data access layers for PostgreSQL, MySQL, or SQLite databases.
  • Full-stack applications use it to query databases from both server-side Node.js code and client-side browser environments via compatible drivers.
  • Teams migrating from less safe query builders or ORMs adopt it to gain compile-time safety without losing SQL control.
  • Projects running on alternative JavaScript runtimes like Deno or Bun use it for consistent database access across platforms.
  • Developers implementing database migrations and schema changes use its integrated migration tooling.

Getting started

Install via npm (npm install kysely) or JSR (jsr add @kysely/kysely). Choose and install a dialect-specific driver for your database, then configure a Kysely instance with your database connection. Documentation and getting-started guides are available at kysely.dev.

When to use it — and when not

Use Kysely when building a TypeScript project that requires direct, type-safe SQL access with support for multiple database systems. It replaces manual SQL string concatenation and provides more type safety than many traditional ORMs. Be aware that it is a query builder, not a full ORM; you must operate your own database connection, and more advanced ORM features like active records or automatic relation loading are not provided.

project readme (upstream, from github) — read inline

Stand With Ukraine

NPM Version Socket Badge Tests License Issues Pull Requests GitHub contributors NPM Downloads JSR Downloads JSR Score

Join the discussion ⠀⠀⠀⠀⠀⠀⠀

Discord Bluesky

Get started

PostgreSQL MySQL MSSQL SQLite PGlite & more!

Kysely

Kysely (pronounce “Key-Seh-Lee”) is a type-safe and autocompletion-friendly TypeScript SQL query builder. Inspired by Knex.js. Mainly developed for Node.js but also runs on all other JavaScript environments like Deno, Bun, Cloudflare Workers and web browsers.

Kysely makes sure you only refer to tables and columns that are visible to the part of the query you're writing. The result type only has the selected columns with correct types and aliases. As an added bonus you get autocompletion for all that stuff.

As shown in the gif above, through the pure magic of modern TypeScript, Kysely is even able to parse the alias given to pet.name and add the pet_name column to the result row type. Kysely is able to infer column names, aliases and types from selected subqueries, joined subqueries, with statements and pretty much anything you can think of.

Of course there are cases where things cannot be typed at compile time, and Kysely offers escape hatches for these situations. See the sql template tag and the DynamicModule for more info.

All API documentation is written in the typing files and you can simply hover over the module, class or method you're using to see it in your IDE. The same documentation is also hosted here.

If you start using Kysely and can't find something you'd want to use, please open an issue or join our Discord server.

Getting started

Please visit our documentation site kysely.dev to get started. We also have a comprehensive API documentation hosted here, but you can access the same documentation in your IDE by hovering over a class/method/property/whatever.

Core team

Project leads

Responsible for project direction, API design, maintenance, code reviews, community support, documentation, and working on some of the most impactful/challenging things.

Honorable mentions

People who had special impact on the project and its growth.


Fernando Hurtado

(1st docs)

Wirekang

(playground)

readme truncated — read the full docs on github

Frequently asked questions

Is kysely free to use?

kysely is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does kysely do?

A type-safe TypeScript SQL query builder

What is kysely written in?

kysely is primarily written in TypeScript. Its source is publicly available at https://github.com/kysely-org/kysely, and it has 14,233 GitHub stars.