bun
Bun is a lightweight, SQL-first ORM for Go that supports PostgreSQL, MySQL, MSSQL, SQLite, and Oracle. It prioritizes readable SQL queries with type safety over abstraction, and includes features like migrations, relationships, and OpenTelemetry integration.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | uptrace/bun |
| Owner | uptrace |
| Primary language | Go |
| License | BSD-2-Clause — OSI-approved |
| Stars | 4.9k |
| Forks | 281 |
| Open issues | 31 |
| Latest release | v1.2.18 (2026-02-28) |
| Last updated | 2026-06-17 |
| Source | https://github.com/uptrace/bun |
What bun is
Bun provides a query builder API layered on Go's `database/sql`, supporting complex CTEs, bulk operations, flexible result scanning into structs/maps/scalars, and struct-tag-based relationship definitions. It emphasizes compile-time type safety and minimal abstraction overhead.
Get the bun source
Clone the repository and explore it locally.
git clone https://github.com/uptrace/bun.gitcd bun# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Requires Go 1.16+ and explicit driver installation per database (e.g., `pgdriver`, `sqliteshim`, or third-party drivers like `go-sql-driver/mysql`).
- Struct tag syntax (`bun:"..."`) defines columns, relationships, and constraints; errors in tags may only surface at runtime.
- No automatic enum or advanced type coercion; custom scanning and marshaling may be needed for complex column types.
- Migrations are code-based (up/down functions); teams must maintain migration files separately from models or use ORM-specific migration registry.
- Connection pooling and lifecycle management remain the responsibility of the caller (use standard `sql.DB` configuration).
When to avoid it — and what to weigh
- NoSQL or document-oriented data — Bun is SQL-only. Projects requiring MongoDB, DynamoDB, or similar non-relational stores need a different ORM or driver.
- Schema-first, auto-migration-heavy workflows — Bun favors explicit, code-driven schema management. Teams heavily reliant on ORM auto-migration from Go struct tags alone may find Bun's migration approach more manual.
- Tightly coupled frameworks (e.g., gRPC-first services with minimal DB logic) — Bun is a database-specific library. Applications better served by a full framework (e.g., Gin, Echo with built-in ORM abstraction) may find standalone use less integrated.
- Strict ORM paradigm (model-first design) — If your team requires heavy model-centric abstractions (Rails-like pattern), Bun's SQL-first philosophy may feel lower-level and less 'magical'.
License & commercial use
BSD-2-Clause (Simplified BSD License): permissive, allows commercial use, modification, and distribution with minimal restrictions. Requires preservation of copyright notice and license text.
BSD-2-Clause is a permissive OSI-approved license. Commercial use is explicitly permitted. Ensure copyright and license notices are preserved in distributions. No warranty or liability protection is provided by the license; review Bun's LICENSES file for any additional disclaimers.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Strong |
| Assessment confidence | High |
Bun uses parameterized queries (via `database/sql`) to prevent SQL injection when used correctly; always bind user input via query parameters, not string concatenation. No security audit details provided in the source data. Applications should conduct standard Go dependency security reviews (e.g., `go list -json -m all | nancy sleuth`) and keep Bun and drivers updated. Connection pooling and authentication are handled by underlying drivers; review driver security posture separately.
Alternatives to consider
sqlc
Type-safe SQL code generation; shifts complexity to code generation rather than runtime queries. Better for teams preferring explicit SQL files over query builders. Does not provide ORM features (relationships, scanning helpers).
GORM
Heavier, more feature-rich ORM with stronger model-centric design, auto-migrations, and more conventions. Better if you want 'Rails-like' feel; less performant on complex queries due to abstraction overhead.
ent
Code-generated entity framework with schema definition in Go code. Stronger static guarantees and graph traversal; more opinionated and requires code generation step. Fewer databases supported than Bun.
Build on bun with DEV.co software developers
Contact a Devco engineer to assess fit, design a POC, or integrate Bun into your existing backend architecture.
Talk to DEV.coRelated on DEV.co
Explore the category and the services that help you build with it.
bun FAQ
Does Bun require a separate daemon or service?
Can I use Bun with an existing schema?
How does Bun handle migrations?
Is Bun suitable for microservices?
Custom software development services
DEV.co is a software development agency delivering custom software development services to companies building on open source. Our software developers and web developers design, integrate, and ship production systems — spanning web development, APIs, AI, data, and cloud. If bun is part of your open-source databases roadmap, our team can implement, customize, migrate, and maintain it.
Ready to evaluate Bun for your Go project?
Contact a Devco engineer to assess fit, design a POC, or integrate Bun into your existing backend architecture.