Simple no-dependency QR code library.
Find a file
Sky Johnson af7dcb367d Add mixed-mode encoding for standard QR codes
Split data into optimal segments (numeric, alphanumeric, byte) using
greedy segmentation with merge heuristics from QR spec Annex J. This
encodes alphanumeric runs at 5.5 bits/char instead of 8, enabling
smaller QR versions for data like TOTP URIs with base32 secrets.
2026-03-14 12:22:19 -05:00
decode.go Add mixed-mode encoding for standard QR codes 2026-03-14 12:22:19 -05:00
encode.go Add mixed-mode encoding for standard QR codes 2026-03-14 12:22:19 -05:00
go.mod update module path 2026-03-14 10:59:43 -05:00
mask.go Add Micro QR support, default ECC to L, SVG single-path, string API 2026-03-14 11:49:19 -05:00
micro.go Add Micro QR support, default ECC to L, SVG single-path, string API 2026-03-14 11:49:19 -05:00
mode.go Add mixed-mode encoding for standard QR codes 2026-03-14 12:22:19 -05:00
placement.go Initial commit 2026-03-14 10:59:00 -05:00
png.go Add Micro QR support, default ECC to L, SVG single-path, string API 2026-03-14 11:49:19 -05:00
qr.go Add mixed-mode encoding for standard QR codes 2026-03-14 12:22:19 -05:00
qr_test.go Add mixed-mode encoding for standard QR codes 2026-03-14 12:22:19 -05:00
readme.md Add Micro QR support, default ECC to L, SVG single-path, string API 2026-03-14 11:49:19 -05:00
rs.go Initial commit 2026-03-14 10:59:00 -05:00
svg.go Add Micro QR support, default ECC to L, SVG single-path, string API 2026-03-14 11:49:19 -05:00
tables.go Add mixed-mode encoding for standard QR codes 2026-03-14 12:22:19 -05:00

qr

A zero-dependency Go library for generating QR codes and Micro QR codes.

Install

go get git.sharkk.net/go/qr

Usage

SVG

svg, err := qr.SVG("https://example.com", 256)

PNG

data, err := qr.PNG("https://example.com", 256)

Encode with options

code, err := qr.Encode("https://example.com", qr.WithECC(qr.M), qr.WithVersion(3))

svg := code.SVG(256)
png, err := code.PNG(256)

Micro QR

Micro QR codes are smaller and suited for short data. Force a version directly or let the encoder pick the smallest one:

// Force a specific Micro QR version
code, err := qr.Encode("12345", qr.WithVersion(qr.VersionM1))

// Auto-select (tries M1M4 first, then standard 110)
code, err := qr.Encode("12345", qr.WithMicro(true))

Micro QR version capabilities:

Version Size Modes ECC Levels
M1 11×11 Numeric L
M2 13×13 Numeric, Alphanum L, M
M3 15×15 Numeric, Alphanum, Byte L, M
M4 17×17 Numeric, Alphanum, Byte L, M, Q

Options

Option Description
WithECC(level) Error correction level: L (default), M, Q, H
WithVersion(v) Force QR version: 110 standard, VersionM1VersionM4 micro
WithMicro(true) Prefer Micro QR during auto version selection

Output

SVG output uses a single <path> element for compact rendering. The module grid is also available directly via Code.Modules for custom renderers.