A simple and efficient command-line tool for generating QR codes in Go that works perfectly in various terminal sizes and no-tty environments.
- 🖥️ Terminal-friendly: Automatically detects terminal size and adapts QR code size
- 🔧 No-TTY support: Works seamlessly when piped or redirected
- 📱 Multiple output formats: Terminal display or PNG file output
- ⚡ Fast and lightweight: Built with Go for optimal performance
- 🎯 Flexible sizing: Auto-detect or user-friendly size scale (1-10)
- 🎨 Border control: Configurable border sizes
go install github.com/kpenfound/qr@latest# Generate QR code for text
qr -text "Hello, World!"
# Using shorthand flag
qr -t "https://example.com"# Specify size manually (1-10 scale)
qr -t "Custom size" -s 5
# Save to PNG file
qr -t "Save to file" -o qrcode.png
# Remove border
qr -t "No border" -b 0
# Quiet mode (suppress extra output)
qr -t "Quiet mode" -q# Read from stdin
echo "Pipe input" | qr -t -
# Chain with other commands
curl -s https://api.github.com/users/octocat | jq -r .html_url | qr -t -| Flag | Shorthand | Default | Description |
|---|---|---|---|
--text |
-t |
required | Text to encode in QR code |
--size |
-s |
0 (auto) |
Size scale 1-10 (0 for auto-detect, 1=smallest, 10=largest) |
--output |
-o |
stdout | Output PNG file path |
--quiet |
-q |
false |
Suppress extra output |
--border |
-b |
2 |
Border size (0 to disable) |
The size parameter uses a user-friendly scale that maps to valid QR code dimensions:
| Size | Dimensions | Description |
|---|---|---|
1 |
25×25 | Smallest valid QR code |
2 |
29×29 | Very small |
3 |
33×33 | Small |
4 |
37×37 | Small-medium |
5 |
41×41 | Medium (good default) |
6 |
45×45 | Medium-large |
7 |
49×49 | Large |
8 |
53×53 | Very large |
9 |
57×57 | Extra large |
10 |
61×61 | Largest |
Note: All sizes produce valid, scannable QR codes. The dimensions correspond to official QR code version standards.
qr -t "https://github.com"qr -t "Small" -s 1qr -t "Medium" -s 5qr -t "Large no border" -s 10 -b 0qr -t "WIFI:T:WPA;S:MyNetwork;P:MyPassword;;" -o wifi.pngcat url_list.txt | head -1 | qr -t - -o first_url.pngMIT License