AI agents: Read [llms.txt](https://kysely.dev/llms.txt) for the documentation index and links to Markdown (.md) versions of individual pages. Read [llms-full.txt](https://kysely.dev/llms-full.txt) for the full documentation in one file.

# Introduction

Kysely (pronounced “Key-Seh-Lee”) is a type-safe and autocompletion-friendly TypeScript SQL query builder. Inspired by Knex. Mainly developed for [node.js](https://nodejs.org/en/) but also runs on all other JavaScript environments like [deno](https://deno.land/) and [bun](https://bun.sh/).

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.

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](https://kysely-org.github.io/kysely-apidoc/interfaces/Sql.html) and the [DynamicModule](https://kysely-org.github.io/kysely-apidoc/classes/DynamicModule.html#ref) 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 available in the [Kysely API reference](https://kysely-org.github.io/kysely-apidoc/).

## Choosing a query builder?[​](#choosing-a-query-builder "Direct link to Choosing a query builder?")

Explore the [comparisons](https://kysely.dev/docs/category/comparisons.md) for SQL query builders, ORMs, and SQL workflows in TypeScript.

## Looking for help?[​](#looking-for-help "Direct link to Looking for help?")

If you start using Kysely and can't find something you'd want to use, please [open an issue](https://github.com/kysely-org/kysely/issues) or [join our Discord server](https://discord.gg/xyBJ3GwvAm).
