Most Go developers don't need a web framework anymore. Since Go 1.22, the router in net/http matches HTTP methods and path parameters, which were the main reasons people reached for Gin, Echo, Fiber or Chi in the first place. Start with the standard library and add a framework when you know which missing piece you want.
The frameworks are worth knowing anyway, because they're small. Gin, Echo and Chi are thin layers over net/http, and even Fiber, which replaces it, fits in one package. Go's standard library does most of the work, so a Go "framework" is mostly a router plus a few helpers.
I wrote the same small users API in all five and benchmarked them with a JSON endpoint and a Postgres endpoint.
TL;DR
- net/http is good enough for most APIs since Go 1.22. You write more code per handler and build your own helpers for route groups, binding and validation.
- Chi adds route groups and middleware chaining to
net/httpand nothing else. Your handlers stay plainnet/httphandlers. - Gin and Echo come with request binding and route groups built in, and Gin validates requests out of the box. Gin has the biggest ecosystem. Echo has the cleanest error handling.
- Fiber was the fastest in the benchmark, 16% ahead of
net/httpon plain JSON and 7.5% ahead with a Postgres query. It runs on fasthttp instead ofnet/http, so it has no native HTTP/2 and doesn't work with standard middleware. - In a real API the database is the bottleneck, so pick the one whose code you like writing.
Which Go web framework should you pick?
| If… | Pick |
|---|---|
| You're not sure what to pick | net/http, good enough for most cases |
| You miss route groups and middleware chaining | Chi, the smallest step up from the standard library |
| You want something stable and batteries included so you can build | Gin or Echo (I use Gin) |
| You need every bit of speed, or you miss Express.js | Fiber, for API gateways and reverse proxies |
All five are maintained and used in production, so any of them is a safe pick. They differ in how much code you write per handler and how close you stay to the standard library.
net/http: the standard library
net/http gives you an HTTP server and a router called ServeMux. Before Go 1.22 the router couldn't match on HTTP method and had no path parameters, so every GET vs POST check and every ID in the URL was code you wrote yourself. Since Go 1.22 (February 2024), a pattern can include the method and wildcards:
example.gogopackage main import ( "encoding/json" "errors" "net/http" "net/mail" ) type CreateUserRequest struct { Name string `json:"name"` Email string `json:"email"` } func main() { mux := http.NewServeMux() mux.HandleFunc("POST /users", createUser) mux.HandleFunc("GET /users/{id}", func(w http.ResponseWriter, r *http.Request) { user, err := users.Get(r.Context(), r.PathValue("id")) if errors.Is(err, ErrNotFound) { http.Error(w, "user not found", http.StatusNotFound) return } if err != nil { http.Error(w, "could not load user", http.StatusInternalServerError) return } w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(user) }) http.ListenAndServe(":8080", mux) } func createUser(w http.ResponseWriter, r *http.Request) { var req CreateUserRequest if err := json.NewDecoder(r.Body).Decode(&req); err != nil { http.Error(w, "invalid JSON body", http.StatusBadRequest) return } if req.Name == "" { http.Error(w, "name is required", http.StatusBadRequest) return } if _, err := mail.ParseAddress(req.Email); err != nil { http.Error(w, "email is invalid", http.StatusBadRequest) return } user, err := users.Create(r.Context(), req.Name, req.Email) if err != nil { http.Error(w, "could not create user", http.StatusInternalServerError) return } w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusCreated) json.NewEncoder(w).Encode(user) }
users is a small store with Create and Get methods. It's the same in every example, so it isn't shown.
The method goes inside the pattern string, as in "POST /users". I find that a bit ugly, but it works. The {id} wildcard comes back out with r.PathValue, and handlers can be named functions or inline closures.
The create handler is where the boilerplate goes. It decodes the body, checks each field, sets the header, sets the status and encodes the response. In Gin, Echo and Fiber, binding and the JSON response are one call each.
Route groups and middleware in net/http
There are no route groups. If every route under /admin needs the same auth check, you either wrap each handler by hand or mount a second mux under the prefix:
example.gogofunc routes() http.Handler { mux := http.NewServeMux() mux.HandleFunc("POST /users", createUser) admin := http.NewServeMux() admin.HandleFunc("GET /admin/users", listUsers) admin.HandleFunc("DELETE /admin/users/{id}", deleteUser) mux.Handle("/admin/", requireAdmin(admin)) return logRequests(recoverPanics(mux)) } func requireAdmin(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.Header.Get("X-Role") != "admin" { http.Error(w, "admin only", http.StatusForbidden) return } next.ServeHTTP(w, r) }) }
There is no middleware chaining either. A chain is nested function calls, like the last line of routes. When only some routes need a middleware, you wrap those handlers yourself, and nothing checks that you remembered. It's easy to leave one route unprotected.
Go middleware best practices covers how to write these wrappers well.
The standard library also has no request binding or validation. You decode the JSON and check every field by hand. Most teams on net/http end up writing a few helpers, such as a writeJSON and a decodeAndValidate, to cut the repetition.
Pros
- Zero dependencies, and the Go 1 compatibility promise means code you write today keeps compiling.
- HTTP/2 over TLS with no configuration.
- What you learn carries over. Gin, Echo and Chi all run on
net/http, so knowing it means you already understand how they work.
Cons
- No binding of requests into structs, and no validation.
- No route groups or middleware chaining.
- Consistent error responses are your job.
- More code per handler, or a set of helpers you write and maintain.
Gin: the most popular Go web framework
Gin is the most popular of the five, with about 89,500 GitHub stars. It came out in 2014 with a Martini-like API and better performance, and because it was early there are years of tutorials, answers and community middleware for it.
The same API in Gin is much shorter:
example.gogopackage main import ( "errors" "net/http" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" ) type CreateUserRequest struct { Name string `json:"name" binding:"required"` Email string `json:"email" binding:"required,email"` } func main() { r := gin.Default() r.Use(cors.Default()) r.POST("/users", createUser) r.GET("/users/:id", getUser) admin := r.Group("/admin", requireAdmin()) admin.GET("/users", listUsers) admin.DELETE("/users/:id", deleteUser) r.Run(":8080") } func createUser(c *gin.Context) { var req CreateUserRequest if err := c.ShouldBindJSON(&req); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } user, err := users.Create(c.Request.Context(), req.Name, req.Email) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": "could not create user"}) return } c.JSON(http.StatusCreated, user) } func getUser(c *gin.Context) { user, err := users.Get(c.Request.Context(), c.Param("id")) if errors.Is(err, ErrNotFound) { c.JSON(http.StatusNotFound, gin.H{"error": "user not found"}) return } if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": "could not load user"}) return } c.JSON(http.StatusOK, user) } func requireAdmin() gin.HandlerFunc { return func(c *gin.Context) { if c.GetHeader("X-Role") != "admin" { c.AbortWithStatusJSON(http.StatusForbidden, gin.H{"error": "admin only"}) return } c.Next() } }
ShouldBindJSON decodes the body into the struct and validates it in one step. The rules live in the binding struct tags: the name is required, and the email is required and must look like an email address. Gin uses go-playground/validator under the hood.
r.Group creates a route group with its own middleware. Every route you add to the admin group runs the admin check, so you can't forget it on a new route.
The gin-contrib organization has community middleware for CORS, sessions, gzip, request IDs, timeouts and more. If you need a middleware, someone has probably written it, and you attach it with Use like the CORS line above.
Pros
- Binding and validation built in.
- Route groups with middleware.
- The biggest ecosystem of the four frameworks, with gin-contrib and over a decade of answers online.
- No breaking changes in more than ten years on version 1.
- Fast enough for nearly every API.
Cons
- Handlers take a
*gin.Contextinstead ofhttp.ResponseWriterand*http.Request. Moving off Gin means rewriting them. gin.WrapFplugs a plainnet/httphandler into Gin, but that handler then gets none of Gin's binding or JSON helpers, which is most of the reason to use Gin.- Some developers find it bloated for what it does.
- Releases are slow. The latest, 1.12.0, came out in February 2026.
Echo: handlers that return errors
Echo has about 33,000 stars and was first released in 2015 by LabStack, a software studio. Version 5 came out in January 2026.
The create handler looks a lot like Gin's:
example.gogopackage main import ( "errors" "net/http" "github.com/go-playground/validator/v10" "github.com/labstack/echo/v5" "github.com/labstack/echo/v5/middleware" ) type CreateUserRequest struct { Name string `json:"name" validate:"required"` Email string `json:"email" validate:"required,email"` } type requestValidator struct { v *validator.Validate } func (rv *requestValidator) Validate(i any) error { if err := rv.v.Struct(i); err != nil { return echo.NewHTTPError(http.StatusBadRequest, err.Error()) } return nil } func main() { e := echo.New() e.Validator = &requestValidator{v: validator.New()} e.Use(middleware.RequestLogger(), middleware.Recover()) e.POST("/users", createUser) e.GET("/users/:id", getUser) admin := e.Group("/admin", requireAdmin) admin.GET("/users", listUsers) admin.DELETE("/users/:id", deleteUser) e.Start(":8080") } func createUser(c *echo.Context) error { var req CreateUserRequest if err := c.Bind(&req); err != nil { return err } if err := c.Validate(&req); err != nil { return err } user, err := users.Create(c.Request().Context(), req.Name, req.Email) if err != nil { return err } return c.JSON(http.StatusCreated, user) } func getUser(c *echo.Context) error { user, err := users.Get(c.Request().Context(), c.Param("id")) if errors.Is(err, ErrNotFound) { return echo.NewHTTPError(http.StatusNotFound, "user not found") } if err != nil { return err } return c.JSON(http.StatusOK, user) } func requireAdmin(next echo.HandlerFunc) echo.HandlerFunc { return func(c *echo.Context) error { if c.Request().Header.Get("X-Role") != "admin" { return echo.NewHTTPError(http.StatusForbidden, "admin only") } return next(c) } }
Binding is built in, but Echo doesn't ship a validator. You register one when you set up the server. The example uses go-playground/validator, the same library Gin uses, wrapped in a small type with a Validate method.
The big difference is error handling. An Echo handler returns an error, and Echo's central HTTPErrorHandler turns it into a response. Every error ends up in one place, so the error format and the logging are the same for every route.
You can build the same thing in Gin with a middleware. Then everyone on the team has to follow that convention, and nothing enforces it.
Routing works like Gin's, with groups that take middleware. Echo ships most of its middleware (logging, recovery, CORS, rate limiting, gzip and more) in its own middleware package, where Gin leaves that to the community.
Pros
- Handlers return errors, and one error handler formats them all.
- Binding built in, plus official middleware in the same repository.
- Route groups with middleware.
Cons
- You bring and wire up your own validator.
- A smaller ecosystem than Gin, with fewer tutorials and fewer companies using it.
- Handlers take
*echo.Context, so moving off Echo means rewriting them, the same as with Gin.
Fiber: the Express-style framework
Fiber has about 40,000 stars. It's popular with developers coming from Node, because its API is modeled on Express. If you've written app.get("/users/:id", ...) in Express, Fiber will feel familiar.
The main reason people pick Fiber is speed. Gin, Echo and Chi all run on net/http, while Fiber runs on fasthttp, a separate HTTP engine built to avoid memory allocations. That is how it gets ahead in benchmarks.
example.gogopackage main import ( "errors" "log" "github.com/go-playground/validator/v10" "github.com/gofiber/fiber/v3" "github.com/gofiber/fiber/v3/middleware/logger" "github.com/gofiber/fiber/v3/middleware/recover" ) type CreateUserRequest struct { Name string `json:"name" validate:"required"` Email string `json:"email" validate:"required,email"` } type structValidator struct { v *validator.Validate } func (sv *structValidator) Validate(out any) error { return sv.v.Struct(out) } func main() { app := fiber.New(fiber.Config{ StructValidator: &structValidator{v: validator.New()}, }) app.Use(logger.New(), recover.New()) app.Post("/users", createUser) app.Get("/users/:id", getUser) admin := app.Group("/admin", requireAdmin) admin.Get("/users", listUsers) admin.Delete("/users/:id", deleteUser) log.Fatal(app.Listen(":8080")) } func createUser(c fiber.Ctx) error { var req CreateUserRequest if err := c.Bind().Body(&req); err != nil { return fiber.NewError(fiber.StatusBadRequest, err.Error()) } user, err := users.Create(c.Context(), req.Name, req.Email) if err != nil { return err } return c.Status(fiber.StatusCreated).JSON(user) } func getUser(c fiber.Ctx) error { user, err := users.Get(c.Context(), c.Params("id")) if errors.Is(err, ErrNotFound) { return fiber.NewError(fiber.StatusNotFound, "user not found") } if err != nil { return err } return c.JSON(user) } func requireAdmin(c fiber.Ctx) error { if c.Get("X-Role") != "admin" { return fiber.NewError(fiber.StatusForbidden, "admin only") } return c.Next() }
Like Echo, handlers return errors and there's no validator included. You plug one in through StructValidator in the config, and Bind().Body runs it after decoding. I think this is the cleanest-looking code of the five.
Fiber reuses request memory
Fiber reuses the request context and its buffers between requests to avoid allocations. Values you read from it, such as a path parameter or a header, are only valid until the handler returns. If you keep one around after that, for example in a goroutine or a cache, the next request can overwrite it.
example.gogofunc deleteUser(c fiber.Ctx) error { // The goroutine outlives the handler, so copy the ID first. id := strings.Clone(c.Params("id")) go auditLog.Record("user.deleted", id) return c.SendStatus(fiber.StatusNoContent) }
You can also set Immutable: true in fiber.Config, which copies these values for you and gives up some of the speed.
Pros
- The fastest of the five in my benchmark.
- Lots of middleware in the core repository (CORS, rate limiting, caching, sessions, CSRF and more).
- Clean, Express-like API.
Cons
- No native HTTP/2, because fasthttp only speaks HTTP/1.1. You terminate HTTP/2 at a proxy in front of it.
- Request values are reused, so you have to copy anything that outlives the handler.
- It isn't built on
net/http, so standard middleware and handlers need theadaptorpackage. Many Go developers avoid Fiber for that reason, because they prefer to stay close to the standard library.
Chi: a router, not a framework
Chi has about 23,000 stars. It takes net/http and adds the missing router features, route groups and middleware chaining, without adding a new handler type.
example.gogopackage main import ( "encoding/json" "errors" "net/http" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" ) func routes() http.Handler { r := chi.NewRouter() r.Use(middleware.RequestID, middleware.Logger, middleware.Recoverer) r.Route("/users", func(r chi.Router) { r.Post("/", createUser) r.Get("/{id}", getUser) }) r.Route("/admin", func(r chi.Router) { r.Use(requireAdmin) r.Get("/users", listUsers) r.Delete("/users/{id}", deleteUser) }) return r } func getUser(w http.ResponseWriter, r *http.Request) { user, err := users.Get(r.Context(), r.PathValue("id")) if errors.Is(err, ErrNotFound) { http.Error(w, "user not found", http.StatusNotFound) return } if err != nil { http.Error(w, "could not load user", http.StatusInternalServerError) return } w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(user) }
The handler is the same as the net/http one, down to r.PathValue, which Chi v5 fills in for you. createUser and requireAdmin are also unchanged from the standard library version.
Chi only adds the router on top. Use chains middleware, and Route creates a group that can have its own.
Pros
- 100% compatible with
net/http. Any standard handler or middleware works, and you can drop Chi later without touching your handlers. - No external dependencies, and the router is about 1,000 lines of code.
- A useful set of optional middleware in
chi/middleware.
Cons
- Very bare. Binding, validation, error handling and anything else beyond routing you build yourself, the same as with the standard library.
Benchmark: which Go framework is fastest?
I built two endpoints in each framework:
- JSON: return a small JSON object.
- Postgres: read one row from Postgres by primary key and return it as JSON.
Every server was limited to one CPU core, and hey sent requests over 50 concurrent connections. I recorded requests per second and the p99 latency, which means 99% of requests finished faster than that.

| Framework | JSON p99 | Postgres p99 |
|---|---|---|
| net/http | 1.6 ms | 3.8 ms |
| Chi | 1.6 ms | 4.1 ms |
| Gin | 2.0 ms | 3.7 ms |
| Echo | 1.7 ms | 6.0 ms |
| Fiber | 1.2 ms | 3.4 ms |
The four frameworks built on net/http are within 3% of each other on the JSON endpoint. Chi and Gin cost almost nothing on top of the standard library. Echo had the slowest p99 on the Postgres endpoint, at 6.0 ms, and this run doesn't show why.
Fiber won both tests. It handled 16% more requests than net/http on plain JSON, and 7.5% more once each request read a row from Postgres. The gap shrinks as soon as a request does real work, because the framework's share of the time per request gets smaller.
A real API endpoint usually does more than one indexed read. It runs several queries, calls other services and checks permissions, so the framework's share drops further. Fiber's speed matters when the server does almost nothing per request at very high traffic, such as an API gateway or a reverse proxy.
How I measured
- Go 1.27.1, Gin 1.12.0, Echo 5.4.6, Fiber 3.7.0, Chi 5.5.0, Postgres 17.
- Apple M2 Pro with 32 GB of RAM. Each server was limited to one CPU core.
- Load from
heywith 50 concurrent connections. - Each test ran 5 times for 15 seconds, and the table shows the average. The framework order was rotated between runs, and other containers were stopped.
These numbers come from my machine. Your hardware and whatever else is running will change them, but the shape should hold: the net/http frameworks close together, and Fiber a bit ahead.
Why I still use Gin
I use Gin, and I'm not switching to Fiber, even though Fiber won the benchmark and I like its syntax.
The framework isn't my bottleneck. In the APIs I build, the time goes to the database, and the benchmark shows how quickly a single query eats Fiber's lead. Switching frameworks wouldn't make my app noticeably faster.
Gin also does everything I need. I've used it for years with no complaints, so a rewrite has nothing to offer me.
If I do switch one day, it will be to the standard library. Right now net/http still misses too much for me (binding, validation, route groups), and I'd rather spend my time on business logic than maintain those helpers myself. Each Go release closes some of that gap.
Go has no Rails, and that's fine
If you come from Python, Ruby or PHP, you might expect a Go equivalent of Django, Rails or Laravel. Go goes the other way. The popular frameworks are small, and the big full-stack projects that copy Rails or Laravel never caught on in the Go community.
The standard library already covers what those frameworks provide in other languages: an HTTP server, routing, JSON, templates, a database interface and testing. A Go framework only has to fill a few gaps.
So which of these five you pick matters less than it seems. Your project structure and how you handle errors and the database will shape the codebase more than the router does.
If you want to build a production API on the standard library, my course Build a Billing REST API from Scratch starts from an empty folder and uses no framework. It covers Postgres, middleware, validation, multi-tenancy, API keys, scopes and roles, and testing.
Related reading:
- Go middleware best practices for the wrappers the standard library leaves to you.
- Next.js Now Runs Go, where every route handler is a plain
net/httphandler. - HTTP & Networking for handlers, path values, JSON bodies and middleware in
net/http.
FAQ
Do I need a framework for a Go web API?
No. Since Go 1.22, net/http routes by method and path parameter, and it handles JSON, middleware and HTTP/2 without any dependencies. A framework saves you some code for binding, validation and route groups. Start with the standard library and add Chi, Gin or Echo if you find yourself writing those helpers over and over.
Is Fiber faster than Gin?
Yes, in my benchmark. On one CPU core with 50 connections, Fiber served 63,869 req/s against Gin's 53,499 on a plain JSON endpoint, about 19% more. With a Postgres query per request the gap shrank to 20,075 against 18,662, about 8%. In an API where the database does real work, the difference is too small to notice.
Is Gin still a good choice in 2026?
Yes. Gin is the most popular Go web framework, with about 89,500 GitHub stars, and it has stayed on version 1 without breaking changes for over a decade. Releases are slower than for Echo or Fiber, with 1.12.0 in February 2026, but it is stable and has the largest set of community middleware.
Should I use Chi or net/http?
Use plain net/http if you have a handful of routes. Pick Chi when you want route groups and middleware chaining without changing how you write handlers. Chi handlers are standard net/http handlers and r.PathValue works the same, so you can switch between the two later with little effort.
Does Fiber support HTTP/2?
Not natively. Fiber runs on fasthttp, which only supports HTTP/1.1. If you need HTTP/2, put a reverse proxy such as nginx, Caddy or a CDN in front of Fiber and terminate HTTP/2 there. Gin, Echo, Chi and net/http all serve HTTP/2 over TLS through the standard library.
Sources
- Go 1.22 release notes, enhanced routing patterns: https://go.dev/doc/go1.22#enhanced_routing_patterns
- Go 1 and the future of Go programs (compatibility promise): https://go.dev/doc/go1compat
- Go standard library, net/http (HTTP/2 support,
Request.PathValue): https://pkg.go.dev/net/http - gin-gonic/gin repository and releases: https://github.com/gin-gonic/gin
- gin-contrib middleware: https://github.com/gin-contrib
- labstack/echo repository and v5 releases: https://github.com/labstack/echo
- gofiber/fiber repository: https://github.com/gofiber/fiber
- Fiber docs, zero allocation and
Immutable: https://docs.gofiber.io/ - valyala/fasthttp: https://github.com/valyala/fasthttp
- go-chi/chi repository: https://github.com/go-chi/chi
- go-playground/validator: https://github.com/go-playground/validator
- GitHub star counts from the GitHub API on 21 November 2026.
- Benchmark: my own runs on an Apple M2 Pro with Go 1.27.1, Gin 1.12.0, Echo 5.4.6, Fiber 3.7.0, Chi 5.5.0 and Postgres 17.
