Skip to main content

Tips on Creating the Smallest Possible QR Codes

Qr-Codes Programming
Ryan Gibson
Author
Ryan Gibson
Quantitative Analyst | Computer Scientist
Table of Contents

The basic advice
#

If you just want to know how to make the smallest possible standard QR code for a website,

  1. Use uppercase and no more than 25 characters (0–9, A–Z, space, and $%*+-./:).
  2. If using non-alphanumeric characters, use no more than 17 characters.
  3. Include http:// or https:// at the start of your URL for compatibility with all QR readers. This effectively limits you to 18 alphanumeric characters or 10 non-alphanumeric characters.

This will give you a 21x21 pixel (version 1) standard QR code.

Two QR codes. The one one the left is about 30% smaller than the one on the right.
Two QR codes for the same URL. Using uppercase takes 21x21 pixels (left) while lowercase takes 25x25 pixels (right).

You can generate these on your own with these two Python commands.

import segno

segno.make_qr("HTTPS://RYANAGIBSON.COM").show()
segno.make_qr("https://ryanagibson.com").show()

What about error correction?
#

When creating small QR codes, you may want to enforce specific error correction levels. Higher correction levels enable faster and easier scanning, but decrease the maximum number of characters that you can fit in a 21x21 QR code.

Four levels are available, each offering different corruption tolerances and data storage capacities.

Error correction levelL (Low)M (Medium)Q (Quartile)H (High)
Data corruption allowed~7%~15%~25%~30%
Error correction levelAlphanumeric character limitByte character limit
L (Low)2517
M (Medium)2014
Q (Quartile)1611
H (High)107

For example, the following QR codes are all for HTTPS://RYGI.ME with the maximum amount of data corruption shown.1 Despite this, they should still scan correctly.

Four black-and-white QR codes above the same QR codes in black and blue, but with increasing amounts of
corruptions in red as you move left to right.
Left to right: QR codes with low, medium, quartile, and high error correction. Top: codes with no corruptions. Bottom: the same codes with data sections shown in blue and mock corruptions shown in red.

As usual, error correction also lets you add in artistic embellishments, even with the tiny size! This obviously affects the error correction’s effectiveness, but can make your QR code more eye-catching. Here are a few examples I played around with.

Eight QR codes displayed in a grid. The top three include "RG" in the design in various positions and sizes. Two
more include "RYAN", each displayed in black-and-white and again with the "RYAN" in blue. The final QR code includes a
large "G".
Eight QR codes that all point to the same website. They have been intentionally corrupted to make the design more interesting and unique while maintaining readability.

In fact, with slight tweaks to the URL, you can artistically corrupt the QR code beyond the theoretical limits of error correction! This would be most useful if you set up redirects to the desired page, but short domains are often explicitly set up for redirection anyway.

Below are two examples where a 15x5 pattern is incorporated into the design. This region of 75 pixels is relatively massive considering that a version 1 QR code has a data capacity of only 136 bits. Indeed, the corrupted region is more than 150% the maximum amount this QR code can normally correct!

Two QR codes that include a large "RYAN" in the design, each displayed in black-and-white and again with the
"RYAN" in blue.
Left: QR code for HTTP://RYGI.ME/+. Right: QR code for HTTP://RYGI.ME/8. They have been very heavily corrupted for design purposes (shown in blue), but still scan correctly.

Complete tables of QR code character limits
#

If you’re interested in a more comprehensive reference of the character limits for QR codes, please refer to “Complete Tables of QR Code Character Limits”.

See also and references
#

  • The segno Python package for generating standard QR codes and the significantly less supported (and seemingly proprietary) Micro QR codes.
    • The smallest Micro QR code is 11x11 pixels, but could only hold enough data to store a URL (with the http:// prefix) in the 15x15 pixel variant. That one could hold up to HTTP://RYGI.ME.
    • The largest Micro QR code is 17x17 pixels, which could hold up to HTTP://RYANGIBSON.DEV.
  • Wikipedia’s QR Code article for a general overview of the standard, its design, features, etc.
  • Denso Wave’s What is a QR Code? which discusses more advanced concepts and features of the code. One interesting feature is to split the data into multiple chunks, each with its own encoding, for even more optimal storage.

  1. The last one with high error correction drops the HTTPS://, so it will scan as text rather than a URL on some systems. For websites, version 1-H is essentially impossible since HTTP://R.G is already 10 characters and single-character TLDs do not currently exist. ↩︎

Related

Complete Tables of QR Code Character Limits
Extra Qr-Codes Programming
A reference for standard QR code data capacities in the common input modes.
Animated Cellular Automaton QR Codes
Qr-Codes Cellular-Automata Video
An experiment in using randomized cellular automata to generate QR codes that remain valid on every frame.
Steganography: Hiding Data Inside Data
Steganography Programming Github Cybersecurity
A general introduction to hiding information in plain sight, its uses in the real-world, and how it works in digital mediums.