Search tools, AI agents, MCP servers
Submit a tool

Search iThub

Search tools, categories and collections. Type at least two characters.

Explore all tools
↑ ↓ to explore resultsEnter to open · Esc to close

Gin

MIT-licensed HTTP web framework for Go with a radix tree router, middleware, binding and rendering

Web Frameworks & UI LibrariesOpen sourcev1.12.0

Gin at a glance

Pricing
Open source
Deployment
Self-hosted
License
Open source
Version
v1.12.0February 28, 2026
Language
Go
Data location
Gin is a library compiled into the developer's own Go application and runs wherever that application is deployed; the project operates no hosted service and receives no application data.
Maker
gin-gonic
Founded
2014

What is Gin?

Gin is an HTTP web framework for the Go programming language, maintained in the gin-gonic organization on GitHub and released under the MIT license. The project describes it as a framework with a Martini-like API and performance up to 40 times faster than Martini, a result it credits to httprouter; Gin uses its own customized version of that router. The README names REST APIs, web applications and microservices as its main use, and the introduction lists a radix tree router without reflection, middleware chains, panic recovery, JSON validation, route groups, error collection and built-in rendering as its core features.

Gin is distributed as a Go module, github.com/gin-gonic/gin. The quickstart adds it with go get -u github.com/gin-gonic/gin inside a module created with go mod init, and the README notes that a plain import is enough for Go to fetch it during the build. There are no binaries, installers or hosted service: Gin is compiled into the application that uses it. The API reference is published on pkg.go.dev, and the user guide on gin-gonic.com is available in English, Simplified and Traditional Chinese, Japanese, Korean, Spanish, Turkish, Persian, Portuguese, Russian, Indonesian and Arabic. The Go project's own tutorial, Developing a RESTful API with Go and Gin, uses Gin as its example framework.

The current release is Gin v1.12.0, published on February 28, 2026. According to the release announcement, it adds BSON rendering, the context helpers GetError, GetErrorSlice and Delete, encoding.UnmarshalText support in URI and query binding, an engine option to route on the escaped request path, Protocol Buffers in content negotiation and colored latency in the default logger. It also reduces allocations in the router tree, lets the logger skip query strings, always trusts X-Forwarded-For headers on Unix socket connections, and fixes ClientIP handling for multiple X-Forwarded-For headers and a file descriptor leak in RunFd. The previous release, v1.11.0 of September 2025, introduced experimental HTTP/3 support through quic-go and extended form binding.

Gin v1.12.0 requires Go 1.25 or later; the README, the documentation and the release notes state this minimum. On the master branch, which is not yet part of a release, the go.mod file declares Go 1.26.0, the Run methods set a default ReadHeaderTimeout on the underlying http.Server, and Any also registers the HTTP QUERY method. The v1 API is described by the project as frozen, so that new releases do not break existing code.

Some functions sit outside the core module. WebSocket support is not built in; the documentation shows an integration with gorilla/websocket. Middleware for CORS, sessions, JWT, rate limiting, compression, metrics and tracing lives in the separate gin-contrib organization, and automatic Let's Encrypt certificates come from the gin-gonic/autotls package. Gin itself does not include an ORM or a database layer; the database guide shows Go's database/sql package used alongside it. Other frameworks on iThub are grouped under Web Frameworks & UI Libraries.

Key capabilities

  • Installation as a Go module The quickstart creates a module with go mod init and adds Gin with go get -u github.com/gin-gonic/gin. With module support, importing github.com/gin-gonic/gin is enough for the Go toolchain to fetch it during the build. Gin v1.12.0 requires Go 1.25 or later, and the result is a regular Go binary with no separate runtime.
  • Default and empty engines gin.Default() returns a router with the Logger and Recovery middleware already attached, while gin.New() returns an engine without middleware. router.Run() listens on 0.0.0.0:8080 by default, or on the port in the PORT environment variable, and also accepts an explicit address such as :8080.
  • Radix tree router Routing uses a radix tree based on a customized version of httprouter, with no reflection and no heap allocations during route matching according to the project. Handlers can be registered for each HTTP method, with path parameters, wildcard segments, query strings and redirects documented in the routing section. Since v1.12.0 an engine option can route on the escaped request path.
  • Route groups router.Group("/v1") creates a group that shares a path prefix and middleware, for example to separate API versions or routes that require authorization. The introduction states that groups can be nested without limit and without degrading performance.
  • Middleware chain A middleware has the same signature as a handler, gin.HandlerFunc, and calls c.Next() to pass control on, so code before and after that call runs around the handler. Middleware can be attached globally, to a group or to a single route, and the broader scope runs first. Built-in middleware includes Logger, Recovery and BasicAuth.
  • Panic recovery The Recovery middleware catches a panic raised during a request and returns a 500 response instead of stopping the server. gin.CustomRecovery() accepts a custom handler for the recovered value, and v1.12.0 suppresses http.ErrAbortHandler in recovery and reads stack traces more efficiently.
  • Binding and validation Request data can be bound into structs from JSON, XML, YAML, TOML, URL-encoded and multipart forms, query strings, URI parameters and headers, using struct tags. Validation rules go in the binding tag with go-playground/validator syntax, and custom validators can be registered. The Bind family aborts with a 400 response on error, while ShouldBind returns the error to the handler, as explained in the binding guide.
  • Response rendering *gin.Context renders JSON, XML, YAML, TOML, ProtoBuf and, since v1.12.0, BSON, setting the content type automatically. JSON variants include SecureJSON, JSONP, AsciiJSON and PureJSON. HTML rendering uses Go templates, supports multiple template sets and can embed templates into a single binary.
  • Files, uploads and streaming Static, StaticFile and StaticFS serve directories, single files and embedded file systems. Single and multiple file uploads use FormFile and MultipartForm, with a documented way to limit upload size, and responses can be streamed from any io.Reader or sent as file attachments.
  • Error collection Errors raised while handling a request can be attached to the context and processed centrally, for example by middleware that writes them to a log or a database. Version 1.12.0 adds GetError and GetErrorSlice for type-safe retrieval of values from the context.
  • Logging options The default logger prints method, path, status and latency, with latency colored since v1.12.0. LoggerWithConfig can skip paths such as health checks, use a custom format, control colors, write to a file and omit query strings. The documentation also covers structured logging.
  • Server configuration gin.Engine implements http.Handler, so it can be passed to a standard net/http.Server to set read and write timeouts, header limits and TLS. The server configuration section covers graceful shutdown, running several engines on different ports, HTTP/2 server push, cookies and automatic Let's Encrypt certificates through gin-gonic/autotls. Experimental HTTP/3 support through quic-go was added in v1.11.0.
  • Trusted proxies and client IP SetTrustedProxies defines which IPv4 or IPv6 addresses and CIDR ranges may set client IP headers such as X-Forwarded-For. The trusted proxies page states that Gin trusts all proxies by default and that this is not safe. TrustedPlatform reads the client IP from a CDN header, with predefined values such as Google App Engine and Cloudflare.
  • Run modes and environment variables GIN_MODE accepts debug, release or test, and the same can be set in code with gin.SetMode. Debug mode prints route registration and other diagnostics, and test mode suppresses them. PORT sets the listen port when Run() is called without arguments.
  • JSON encoder build tags Build tags swap the JSON implementation at compile time without code changes: go_json uses go-json, jsoniter uses json-iterator and sonic avx uses ByteDance sonic. The build tag guide notes that sonic requires a CPU with AVX instructions and does not run on ARM, and that only one JSON tag should be set at a time. The nomsgpack tag removes MsgPack rendering.
  • Testing with httptest The testing guide uses Go's net/http/httptest package: a test builds the router, sends a request through router.ServeHTTP with a response recorder and checks status and body. Calling gin.SetMode(gin.TestMode), for example in TestMain, keeps route debug logs out of test output.
  • gin-contrib middleware The gin-contrib organization maintains middleware outside the core module, including CORS, sessions, CSRF protection, JWT, rate limiting, compression, OpenMetrics and Prometheus metrics, tracing, static files and template engines. Each is a separate Go module added with go get, and the gin-gonic/contrib repository collects further community middleware.
  • Published benchmark data The benchmarks page reports results collected on March 15, 2026 with Gin v1.12.0 and Go 1.25.8 on an Apple M4 Pro, using the Go HTTP router benchmark suite. Routing all 203 GitHub API routes took 9,944 ns per operation with 0 bytes and 0 allocations, first among 12 routers in that table, while HttpRouter and HttpTreeMux ranked ahead of Gin for 157 static routes. The page adds that Fiber results use a different request type and should be compared with care.

Where Gin fits

JSON REST APIs and microservices

The README and the Go project's RESTful API tutorial build HTTP endpoints that read and return JSON. A typical service registers handlers on gin.Default(), groups versioned endpoints under prefixes such as /v1, binds request bodies into structs and returns responses with c.JSON. Projects listed on the official users page include the gorush push notification server, the lura API gateway and the photoprism photo application.

Validating incoming requests

The binding guide describes declaring a struct with json, form, uri or header tags and rules in the binding tag, such as required. ShouldBind chooses a decoder from the Content-Type header and returns validation errors to the handler, which can then send its own error response. Separate pages cover default values, array collection formats, custom unmarshalers and binding the body into more than one struct.

Server-rendered pages and static assets

For web applications, LoadHTMLGlob or LoadHTMLFiles load Go templates that handlers render with c.HTML, and static directories are mounted with Static or an embedded file system with StaticFS. The rendering section documents multiple template sets and embedding templates in the compiled binary, so the application can ship as a single file.

Running behind a reverse proxy or CDN

When a Gin service sits behind Nginx, HAProxy, a load balancer or a CDN, ClientIP() depends on the trusted proxy settings. The documentation shows SetTrustedProxies with the proxy addresses, SetTrustedProxies(nil) when no proxy is used, and TrustedPlatform for CDNs that send the client address in their own header. The security guide adds CORS, CSRF, rate limiting and security header middleware.

Observability and testing

The metrics page exposes a /metrics endpoint for Prometheus through gin-contrib/openmetrics, or with a custom middleware based on prometheus/client_golang that labels requests by c.FullPath() to keep label cardinality low. Handlers are tested in process with httptest, without opening a network port, and the FAQ describes live reload during development with the Air tool.

Deployment

The deployment page links guides for Railway, Seenode, Koyeb, Qovery, Render and Google App Engine, and also describes self-hosted deployment configured through PORT, GIN_MODE and code. For self-hosted servers the documentation shows a custom http.Server with timeouts, graceful shutdown and automatic TLS through gin-gonic/autotls, which requires ports 80 and 443 to be reachable from the internet.

Install

go get -u github.com/gin-gonic/gin

Reviews of Gin

No reviews yet

Be the first to share your experience with Gin.

Loading review form…

Found Gin useful? Upvote it todayYour vote helps other IT teams find it in the daily ranking.

Similar to Gin

Compare:Gin vs RuneGin vs RefineGin vs Next.js

  1. RuneRust UI framework with its own GPU renderer, text, layout and springs for desktop, iOS and webWeb Frameworks & UI Libraries138 views
  2. RefineMIT-licensed headless React framework for admin panels, dashboards, internal tools and B2B appsWeb Frameworks & UI Libraries51 views
  3. Next.jsMIT-licensed React framework with App Router, Server Components, Turbopack and self-hosting optionsWeb Frameworks & UI Libraries43 views
  4. SvelteKitWeb application framework built on SvelteWeb Frameworks & UI Libraries31 views
  5. RemixFull-stack TypeScript framework on Web APIs: routing, data, auth, sessions, UI and assets in one remix packageWeb Frameworks & UI Libraries30 views
  6. AstroWeb framework for content-driven sites with zero JS by defaultWeb Frameworks & UI Libraries26 views
  7. NuxtOpen-source full-stack framework for building with VueWeb Frameworks & UI Libraries25 views
  8. TailwindCSSUtility-first CSS framework, MIT-licensed, now backed by ShopifyWeb Frameworks & UI Libraries25 views