knex vs typeorm

knex and typeorm have comparable adoption (17,423,302 vs 18,073,696 downloads per month). knex ships 41% less gzipped JavaScript (86.2 kB vs 146.6 kB), which matters if bundle size is a priority. Both projects are actively maintained.

Metricknextypeorm
Weekly downloads3,940,3904,208,495
Monthly downloads17,423,30218,073,696
GitHub stars20,28536,520
Minified size314.3 kB692.3 kB
Minified + gzipped86.2 kB146.6 kB
Dependencies1410
Open issues715546
Last commit2026-05-042026-05-28
Latest version3.2.101.0.0
LicenseMITMIT

When to choose which

knex

A SQL query builder, not a full ORM.

Choose it when: You want to compose SQL programmatically (and run migrations) without the abstraction of a full ORM.

  • + Close to SQL
  • + Built-in migrations
  • + Lightweight
  • - No models or generated types
  • - Lower-level

typeorm

Decorator-based ORM, popular with NestJS.

Choose it when: Decorator/entity style (e.g. NestJS apps) where you want both Active Record and Data Mapper patterns.

  • + Decorator entities
  • + NestJS-friendly
  • + Active Record + Data Mapper
  • - Uneven maintenance history
  • - Runtime/type edge cases

Feature comparison

Featureknextypeorm
ApproachQuery builderORM
Type safetyLimitedDecorators
Built-in migrations✓ Yes✓ Yes
DatabasesSQL onlySQL + MongoDB
PatternSQL query builderActive Record / Data Mapper

knex

A batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3

typeorm

Data-Mapper ORM for TypeScript and ES2023+. Supports MySQL/MariaDB, PostgreSQL, MS SQL Server, Oracle, SAP HANA, SQLite, MongoDB databases.

Related comparisons

Embed this comparison

A live badge for your README — it updates as the numbers change.

knex vs typeorm downloads
[![knex vs typeorm](https://devcompare.dev/badge/knex-vs-typeorm.svg)](https://devcompare.dev/compare/knex-vs-typeorm)

Data from npm, Bundlephobia and GitHub. Last updated 2026-06-02.