qr is a library for generating QR Codes in pure Go.

go get github.com/AlexEidt/qr


text := "QR Code"
qrcode, err := qr.NewQRCode(text, &qr.Options{Error: "H"})
if err != nil {

qrcode.Render("qr.png", 10)


When building a QR Code, you may specify certain parameters such as the Version, Mode and Error Correction Level.

type Options struct {
	Version int
	Mode    int
	Error   string
Parameter Description
Version The version of the QR Code to be generated. Must be between 1 and 40. Defaults to lowest version that fits the given data.
Mode The mode of the QR Code to be generated. Must be qr.Numeric, qr.AlphaNum, or qr.Byte. The best fit is found based on the given data. See the Supported Modes section below for the characters that can be used in each mode.
Error The error correction level of the QR Code to be generated. Must be L, M, Q, or H. Defaults to L. Level L can correct ~7% of errors, M can correct ~15% of errors, Q can correct ~25% of errors, and H can correct ~30% of errors.

Supported Modes

Currently, only Numeric, Alphanumeric and Binary modes are supported for data encoding.

Mode Character Set
Numeric 0123456789
Alphanumeric 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:
Binary ISO/IEC 8859-1


  • Kanji mode is not supported.
  • Structured Append mode is not supported.
  • Extended Channel Interpretations (ECI) mode is not supported.
  • Model 1 QR Codes are not supported.


The following resources were helpful in building this library:


View Github