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.
| Metric | knex | typeorm |
|---|---|---|
| Weekly downloads | 3,940,390 | 4,208,495✓ |
| Monthly downloads | 17,423,302 | 18,073,696✓ |
| GitHub stars | 20,285 | 36,520✓ |
| Minified size | 314.3 kB✓ | 692.3 kB |
| Minified + gzipped | 86.2 kB✓ | 146.6 kB |
| Dependencies | 14 | 10✓ |
| Open issues | 715 | 546✓ |
| Last commit | 2026-05-04 | 2026-05-28✓ |
| Latest version | 3.2.10 | 1.0.0 |
| License | MIT | MIT |
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
| Feature | knex | typeorm |
|---|---|---|
| Approach | Query builder | ORM |
| Type safety | Limited | Decorators |
| Built-in migrations | ✓ Yes | ✓ Yes |
| Databases | SQL only | SQL + MongoDB |
| Pattern | SQL query builder | Active Record / Data Mapper |
knex
A batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3
Related comparisons
Embed this comparison
A live badge for your README — it updates as the numbers change.
[](https://devcompare.dev/compare/knex-vs-typeorm)Data from npm, Bundlephobia and GitHub. Last updated 2026-06-02.