Skip to main content

Kysely

The type-safe SQL
query builder for TypeScript

Getting startedView on GitHub

Type-safe SQL queries

Kysely lets you write type-safe SQL queries. This eliminates entire classes of errors and lets you sleep peacefully at night.

No magic, just SQL

Kysely is a light abstraction layer over SQL. This makes it easy to reason about performance, and reduces the number of concepts you need to learn to be proficient with the library.

Great autocompletion

By exposing your database schema to the TypeScript compiler, you get autocompletion on table names, column names, aliases, etc.

Multi-dialect support

PostgreSQL, MySQL, or SQLite? We've got you covered. There's also a growing ecosystem of third-party dialects, including PlanetScale, D1, SurrealDB, and more. Learn more.

Runs on every environment

Kysely runs on node.js, the browser, serverless and edge environments, even on Deno! Learn more.

Extensible core

Kysely comes with a plugin system that lets you extend the core with your own functionality. Learn more.

What the internet is saying

Developers are loving Kysely for its simplicity and power.

Tim Griesser's avatar picture
Tim GriesserKnex.js creator, Cypress Staff Eng
👋 First just wanted to say this project looks awesome! Pretty close to what I wish Knex was if I started it now, with the affordances of modern TypeScript instead of 10 years ago when we were stuck in ES5 and Promises weren't even really an official language construct yet.
Orta Therox's avatar picture
Orta TheroxEx-TypeScript team
👋 been using Kysely for a few days in Deno and Node, just wanted to say it's been going really well and it feels like a nice abstraction - kudos!
Niels Sandholt Busch's avatar picture
Niels Sandholt BuschMaersk SWE
We are using Kysely in production at Maersk inventory control!
Guðmundur Bjarni Olafsson's avatar picture
Guðmundur Bjarni OlafssonVercel Principal SWE
I made a strong recommendation internally for using Kysely for a greenfield service that's in the works. Looks very solid. 👌🏻
Catalin Pit's avatar picture
Catalin PitDocumenso SWE
Kysely is fantastic! We use it at @documenso with Prisma.
Dax "thdxr" Raad's avatar picture
Dax "thdxr" RaadSST core team, Terminal co-founder
really excited to see Kysely get more attention - been banging this drum for a while and we've integrated pretty deeply with it at SST incidentally its codebase remains the best Typescript codebase I have ever seen - worth poking around
Julius Marminge's avatar picture
Julius MarmingetRPC & create-t3-app core team
Utterly astounded by how Kysely manages to make all of this typesafe. Seems like no matter how complex you get, it can infer it correctly.
Gal Schlezinger's avatar picture
Gal Schlezingerfnm creator, Vercel SWE
I love SQL, and I love migrations, most tools don’t provide good migration tools and fine grained control like Kysely which is why it’s my favorite.
Yusuke "yusukebe" Wada's avatar picture
Yusuke "yusukebe" WadaHono creator, Cloudflare DevRel
Kysely is great. D1 will be great. This is great.
Harminder Virk's avatar picture
Harminder VirkAdonisJS creator, Medusa SWE
If not Lucid, Kysely is what I would recommend everyone use. It presents itself as a type-safe SQL query builder and delivers 100% on that promise.
"pilcrow"'s avatar picture
"pilcrow"Lucia creator
Ok, so I'm not a big fan of Drizzle. I don't like how I have to import everything when declaring schemas and queries, and I just prefer the simplicity and the overall API of Kysely.
Ben Holmes's avatar picture
Ben HolmesAstro SWE
I really like Prisma for schemas and Kysely for querying. Drizzle feels... younger for schemas, but also quite nice
Theo "t3dotgg" Browne's avatar picture
Theo "t3dotgg" BrowneUploadthing creator, Ping.gg CEO
kysely is dope too. Drizzle and kysely are the frontrunners for "new db tools that really understand JS needs" atm
Shoubhit "nexxel" Dash's avatar picture
Shoubhit "nexxel" Dashcreate-t3-app author, Leapflow CTO
kysely is great btw
Lee "leerob" Robinson's avatar picture
Lee "leerob" RobinsonVercel VP Product
Type-safe SQL queries with PlanetScale and Kysely 😍
Nicholas Griffin's avatar picture
Nicholas Griffinsqs-consumer maintainer, BBC SWE
I don't actually like prisma that much, I prefer Kysely, not an ORM though.
Alberto "gimenete" Gimeno's avatar picture
Alberto "gimenete" GimenoRailway SWE
I'm a happy Kysely user. It's great to see that the code I'm writing now can work with serverless PostgreSQL now!
Guga Guichard's avatar picture
Guga Guichardstring-ts creator, Seasoned Partner
I've been seeing a lot of discussions about ORMs vs raw SQL. What about strongly typed SQL query builders? Kysely is in the sweet spot! Best DX with total freedom I've seen in decades.
Bereket "Bek Cru" Engida's avatar picture
Bereket "Bek Cru" Engidabetter-auth creator
I don’t think they have similar goals from what I see. Drizzle is more dedicated into marketing and having every user possible like prisma but kysely kinda just don’t care about that for most part. And in my experience prisma + kysley is better than drizzle.
Ross Coundon's avatar picture
Ross Coundonleadent digital CTO
I particularly like Kysely here, it's a type-safe query builder and as such doesn't enforce the specifics of an ORM on you, therefore I feel, in the medium-to-long term, it'll save you the time and effort of working around ORM-specific and enforced structures/approaches
Johan Eliasson's avatar picture
Johan EliassonOneLab CTO
Instead of Prisma, I'm testing Kysely, Kysely Codegen, and Atlas. Works great.
R. Alex Anderson's avatar picture
R. Alex AndersonThorium Nova creator
Shout out to Kysely for adding extensive JSDoc comments above the methods. It makes it much easier to figure out how to use it the way I want without having to dig into the docs. (though the docs are vv good too)
Mehul Mohan's avatar picture
Mehul MohanCodedamn Founder
We went with query builder because we did not have more time to waste on ORMs. ORMs might be great but we have the technical capability to pull off just using a query builder. However, we type safety and sanitization for DX and security was a must - hence Kysely.
Sam Cook's avatar picture
Sam CookGamma.io SWE
Kysely is amazing.
Gannon Hall's avatar picture
Gannon HallAstro Labs Founder
Vercel just announced native Postgres support and published Prisma and Kysely templates. I like the DX of Prisma and the type safety of Kysely so I use both via prisma-kysely.
Alisson "thelinuxlich" C.Agiani's avatar picture
Alisson "thelinuxlich" C.AgianiOpensourcerer
Kysely is superior and with each release gets even more awesome
Marvin's avatar picture
MarvinIndie Hacker
I've been saying it many times already, but it's probably one of the best additions to my tech stack. I enjoy writing SQL since I know Kysely 😆
Jiří "Capaj" Špác's avatar picture
Jiří "Capaj" ŠpácLangtail SWE
Kysely is awesome

Try it out for yourself!

Modify the query on the left and view the generated SQL on the right.

Looking for code examples?

From finding a single record to complex joins, our docs have examples to get you started quickly.

Jump right in