Stage 03 · Host · Researched comparison
Best SQL Query Builders for Code in 2026
Kysely is the first pick for TypeScript teams that want type-safe SQL with autocomplete and no ORM layer. Knex.js suits Node.js projects that need a mature query builder plus migrations. jOOQ is the strongest choice for Java and JVM teams working against a real database schema. All three build SQL in application code, so no query text leaves your machine.
By Shihab Mia
Published 22 Nov 2026 · 8 tools compared
We run no ads and no affiliate links at launch. The order of a list follows our published method. See how we score.
Prices are the starting prices vendors list publicly. Plans change, so confirm the current price on the vendor page before you buy.
Key takeaways
- Kysely, Knex.js, Drizzle, PyPika, goqu and Squirrel are free and open source; jOOQ and SQLAlchemy Core have free open-source editions with paid support or commercial licensing options.
- Kysely and Drizzle target TypeScript, Knex.js targets Node.js, jOOQ targets the JVM, and SQLAlchemy Core, PyPika, goqu and Squirrel cover Python and Go.
- These libraries generate SQL strings in your own process, so credentials and query data are not sent to a third-party web page.
- Each tool binds to specific languages and database dialects, so check driver support before you commit.
Who each pick is for
- TypeScript teams that want type-safe SQL without an ORMKysely
- Node.js projects that need a query builder plus migrationsKnex.js
- Java and JVM teams that want SQL generated from a real schemajOOQ
- Python projects that want SQL construction without the ORM layerSQLAlchemy Core
- Python teams that want a small, focused query builderPyPika
- Go developers who want a fluent SQL builder with dialect supportgoqu
- Go teams that want a simple statement builder for database/sqlSquirrel
- TypeScript teams that want a typed query builder with optional schema toolingDrizzle ORM query builder
Comparison
| Tool | Best for | Standout feature | Listed starting price | Free plan or trial |
|---|---|---|---|---|
| 1Kysely | TypeScript teams that want type-safe SQL without an ORM | Strong TypeScript inference for tables and columns | Free (open source) | Free plan |
| 2Knex.js | Node.js projects that need a query builder plus migrations | Mature and widely used | Free (open source) | Free plan |
| 3jOOQ | Java and JVM teams that want SQL generated from a real schema | Generates Java classes from your schema for compile-time checks | See vendor pricing page | Free plan |
| 4SQLAlchemy Core | Python projects that want SQL construction without the ORM layer | Mature and well documented | Free (open source) | Free plan |
| 5PyPika | Python teams that want a small, focused query builder | Lightweight with a readable chained API | Free (open source) | Free plan |
| 6goqu | Go developers who want a fluent SQL builder with dialect support | Fluent API with prepared statements | Free (open source) | Free plan |
| 7Squirrel | Go teams that want a simple statement builder for database/sql | Small API that composes SQL fragments | Free (open source) | Free plan |
| 8Drizzle ORM query builder | TypeScript teams that want a typed query builder with optional schema tooling | Type-safe queries from a TypeScript schema | Free (open source) | Free plan |
How we picked
We picked libraries that build SQL statements in application code, not ORMs with model layers or visual query tools. Criteria were fit for the job, supported languages and databases, licence and price, whether queries run locally rather than through a third-party service, and known limits such as code generation or type-safety gaps. Sources are vendor pages, official documentation and project repositories. Prices and plan details change, so confirm them on the vendor site before you commit.
The tools, one by one
Kysely
Best for typeScript teams that want type-safe SQL without an ORM

What it is and where it fits
Kysely is a type-safe SQL query builder for TypeScript. You define a database interface, and the builder checks column names and result types at compile time. It supports PostgreSQL, MySQL, SQLite, MSSQL and other dialects through separate dialect packages. The API covers selects, joins, subqueries, inserts, updates and deletes, and it can run raw SQL when needed.
The project is open source under the MIT license and ships as an npm package. It does not include migrations or a schema sync tool by default, so teams often pair it with a migration tool. It suits teams already comfortable with SQL who want compiler checks. Teams that want a full ORM with relations and model classes should look elsewhere.
Standout: Strong TypeScript inference for tables and columns
Free (open source), as listed by the vendor (Kysely website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Strong TypeScript inference for tables and columns
- thin layer that stays close to SQL
Drawbacks
- Type safety depends on hand-written or generated types
- smaller ecosystem than Knex.js
Skip it if this limit matters to you: type safety depends on hand-written or generated types.
Verdict. A sensible pick for typeScript teams that want type-safe SQL without an ORM.
Alternatives in this guide: Knex.js, jOOQ, SQLAlchemy Core
Knex.js
Best for node.js projects that need a query builder plus migrations

What it is and where it fits
Knex.js is a SQL query builder for Node.js. It supports PostgreSQL, MySQL, SQLite, MSSQL and Oracle through dialect drivers, and it includes a schema builder and a migration runner. Queries are written as chained method calls and compiled to parameterized SQL for the target dialect.
The library is open source under the MIT license and installs from npm. It has a long release history and broad community usage, which helps when you hit edge cases. TypeScript support exists but is weaker than Kysely or Drizzle, so type-heavy codebases may prefer those. It is a reasonable default for JavaScript backends that want one tool for queries and migrations.
Standout: Mature and widely used
Free (open source), as listed by the vendor (Knex.js website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Mature and widely used
- built-in schema builder and migration tooling
Drawbacks
- Limited TypeScript type safety
- callback-style API feels dated to some teams
Skip it if this limit matters to you: limited TypeScript type safety.
Verdict. A sensible pick for node.js projects that need a query builder plus migrations.
Alternatives in this guide: Kysely, jOOQ, SQLAlchemy Core
jOOQ
Best for java and JVM teams that want SQL generated from a real schema

What it is and where it fits
jOOQ builds SQL in Java and other JVM languages from generated classes that mirror your database schema. That gives compile-time checks on table and column names and close control over dialect-specific SQL. It supports many databases, including PostgreSQL, MySQL, Oracle, SQL Server and SQLite.
The open-source edition is free under the Apache 2.0 license for open-source databases. Commercial editions add support for proprietary databases and extra features, and pricing is listed on the vendor site. The generated-code workflow needs a build plugin and a live schema or DDL input. Teams that want no code generation step may prefer a lighter builder.
Standout: Generates Java classes from your schema for compile-time checks
See vendor pricing page, as listed by the vendor (jOOQ website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Generates Java classes from your schema for compile-time checks
- broad SQL dialect support
Drawbacks
- Commercial editions are paid
- code generation adds a build step
Skip it if this limit matters to you: commercial editions are paid.
Verdict. A sensible pick for java and JVM teams that want SQL generated from a real schema.
Alternatives in this guide: Kysely, Knex.js, SQLAlchemy Core
SQLAlchemy Core
Best for python projects that want SQL construction without the ORM layer

What it is and where it fits
SQLAlchemy Core is the SQL expression layer of SQLAlchemy, a Python database toolkit. You compose statements with Python objects, and the library compiles them to SQL for the target dialect. It supports PostgreSQL, MySQL, SQLite, Oracle, SQL Server and others through dialect modules.
Core is separate from the ORM, so you can use it without mapped classes. It is open source under the MIT license and installs from PyPI. The documentation is extensive, which helps with joins, subqueries and CTEs. The main cost is a learning curve: the expression API is powerful but more verbose than writing a short SQL string by hand.
Standout: Mature and well documented
Free (open source), as listed by the vendor (SQLAlchemy Core website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Mature and well documented
- expression language compiles to dialect-specific SQL
Drawbacks
- Core and ORM concepts can blur for newcomers
- verbose for simple queries
Skip it if this limit matters to you: core and ORM concepts can blur for newcomers.
Verdict. A sensible pick for python projects that want SQL construction without the ORM layer.
PyPika
Best for python teams that want a small, focused query builder

What it is and where it fits
PyPika is a Python library for building SQL queries with a fluent API. It covers selects, joins, filters, grouping, inserts and updates, and it can output SQL for MySQL, PostgreSQL and other dialects. It does not manage connections or run queries, so you pair it with a driver such as psycopg or mysqlclient.
The project is open source under the Apache 2.0 license and installs from PyPI. It is maintained on GitHub by Kayak. Its scope is narrow by design, which keeps it easy to learn. Projects that need schema metadata, migrations or an ORM should use SQLAlchemy instead.
Standout: Lightweight with a readable chained API
Free (open source), as listed by the vendor (PyPika website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Lightweight with a readable chained API
- supports several SQL dialects
Drawbacks
- Smaller community than SQLAlchemy
- fewer advanced features
Skip it if this limit matters to you: smaller community than SQLAlchemy.
Verdict. A sensible pick for python teams that want a small, focused query builder.
goqu
Best for go developers who want a fluent SQL builder with dialect support

What it is and where it fits
goqu is a SQL builder for Go. It provides a chainable API for selects, joins, inserts, updates and deletes, and it can produce prepared statements. Dialects cover PostgreSQL, MySQL, SQLite and SQL Server. It works alongside the standard database/sql package.
The library is open source under the MIT license and installs with go get. It focuses on building SQL rather than mapping rows to structs, so you still handle scanning. Go teams that want compile-time query checks may prefer a code-generation approach. goqu suits teams that want readable builder code and direct control over the generated SQL.
Standout: Fluent API with prepared statements
Free (open source), as listed by the vendor (goqu website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Fluent API with prepared statements
- supports PostgreSQL, MySQL, SQLite and SQL Server
Drawbacks
- Maintained by a small team
- fewer type-safety guarantees than newer Go options
Skip it if this limit matters to you: maintained by a small team.
Verdict. A sensible pick for go developers who want a fluent SQL builder with dialect support.
Squirrel
Best for go teams that want a simple statement builder for database/sql

What it is and where it fits
Squirrel is a Go library for building SQL statements. It offers builders for select, insert, update and delete, plus helpers for where clauses and placeholders. It integrates with the standard database/sql package and leaves execution and row scanning to your code.
The project is open source under the MIT license and installs with go get. It is maintained by Masterminds. The API is deliberately small, which makes it easy to read and test. Because it does not model your schema, mistakes in column names surface at runtime rather than compile time. It suits Go services that want a thin builder without code generation.
Standout: Small API that composes SQL fragments
Free (open source), as listed by the vendor (Squirrel website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Small API that composes SQL fragments
- works directly with database/sql
Drawbacks
- No dialect-specific type checking
- placeholder handling needs care across databases
Skip it if this limit matters to you: no dialect-specific type checking.
Verdict. A sensible pick for go teams that want a simple statement builder for database/sql.
Drizzle ORM query builder
Best for typeScript teams that want a typed query builder with optional schema tooling

What it is and where it fits
Drizzle ORM includes a SQL-like query builder that works from a TypeScript schema definition. You define tables in code, and the builder checks columns and result types. It supports PostgreSQL, MySQL, SQLite and other databases through drivers, and it ships with migration tooling.
The project is open source under the Apache 2.0 license and installs from npm. It is often described as an ORM, but the query builder can be used on its own for typed SQL. Because the schema lives in TypeScript, it can drift from an existing database unless you keep it in sync. Teams that prefer schema-first generation, like jOOQ or Kysely with generated types, may prefer those.
Standout: Type-safe queries from a TypeScript schema
Free (open source), as listed by the vendor (Drizzle ORM query builder website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Type-safe queries from a TypeScript schema
- includes migration tooling
Drawbacks
- Schema is defined in TypeScript rather than generated from the database
- fast-moving API
Skip it if this limit matters to you: schema is defined in TypeScript rather than generated from the database.
Verdict. A sensible pick for typeScript teams that want a typed query builder with optional schema tooling.
Who should use what
TypeScript teams that want compiler-checked SQL should start with Kysely, and teams that also want schema and migration tooling in TypeScript can look at Drizzle. Node.js projects that need one tool for queries and migrations fit Knex.js. Java and JVM teams working against an existing schema get the most from jOOQ. Python teams that want a full expression layer should use SQLAlchemy Core, while small Python scripts fit PyPika. Go services can choose goqu for a fluent builder or Squirrel for a minimal one.
Questions to settle before you buy
What to check before you buy
- Confirm the library supports your database and driver version.
- Check whether type safety comes from generated code, hand-written types or none.
- Verify how the builder handles parameter binding and placeholders for your dialect.
- Review the licence if you ship closed-source software, especially for jOOQ editions.
- Check maintenance activity and release cadence on the project repository.
FAQ
Do these tools send my SQL or data anywhere?
No. They are code libraries that run in your own process and build SQL strings locally. Your queries and credentials stay on your machine or server, unlike third-party web pages that format or validate SQL.
What is the difference between a query builder and an ORM?
A query builder composes SQL statements in code and returns rows or raw results. An ORM maps tables to classes and manages object state. Some projects, like Drizzle and SQLAlchemy, offer both, but the builder part can be used on its own.
Which one is best for TypeScript?
Kysely gives the strongest type inference for hand-written database types. Drizzle offers typed queries plus schema and migration tooling. Knex.js works in TypeScript but has weaker type checks.
Is jOOQ free?
The open-source edition is free under the Apache 2.0 license for open-source databases. Commercial editions that support proprietary databases are paid, and pricing is on the vendor site.
Can I use these with an existing database?
Yes. Kysely, Knex.js, SQLAlchemy Core, PyPika, goqu and Squirrel work against an existing schema without code generation. jOOQ generates classes from your schema, and Drizzle needs a TypeScript schema definition kept in sync with the database.
Sources we checked
Method: how we score · editorial policy.
Change log. First published 22 Nov 2026.