GameParticles
Random & generators

How Do QR Codes Work? Modules, Patterns and Error Levels

How do QR codes work? Each square is a bit, three corner patterns orient the scanner, and error correction repairs damage. With capacity tables and steps.

Updated

A QR code stores data as a grid of dark and light squares called modules, where each module is one bit. Three large corner patterns tell the scanner where the code is and how it is rotated, and built-in error correction lets the data be recovered even if part of the code is damaged. To make one, type your text into the QR Code Generator and download the image.

The parts of a QR code

QR stands for Quick Response. The format was created in 1994 by the Japanese company Denso Wave to track car parts, and it is now an ISO standard. Every code is built from the same pieces:

  • Modules: the small squares. Dark is 1, light is 0.
  • Finder patterns: the three large squares in the top left, top right and bottom left corners. Each is 7 by 7 modules: a dark ring, a light ring and a dark 3 by 3 center.
  • Alignment patterns: smaller squares inside larger codes that help the scanner correct for curved or tilted surfaces. The smallest code has none.
  • Timing patterns: a row and a column of alternating dark and light modules running between the finder patterns. They let the scanner measure the module size.
  • Format information: a short, heavily protected strip next to the finder patterns that records the error correction level and the mask used.
  • Quiet zone: the empty margin around the code. The standard asks for 4 modules of clear space on every side.
  • Data area: everything else. It holds your data and the error correction bytes.

Versions and size

QR codes come in 40 sizes, called versions. Version 1 is 21 by 21 modules, and each version adds 4 modules per side, so the side length is 17 plus 4 times the version number. Version 40 is 177 by 177.

A generator picks the smallest version that fits your data. More data means more modules, which means smaller squares at the same printed size and a code that is harder to scan from a distance.

How text becomes squares

  1. The generator picks an encoding mode. Numeric mode packs digits most tightly. Alphanumeric mode covers digits, uppercase letters and a few symbols. Byte mode handles everything else, including lowercase letters and UTF-8 text. Kanji mode covers Japanese characters.
  2. The data is turned into a bit stream and split into 8-bit codewords.
  3. Reed-Solomon error correction codewords are calculated and appended.
  4. The codewords are placed into the data area in a zigzag path, starting from the bottom right corner.
  5. One of eight mask patterns is applied, flipping some modules to avoid large blank areas and shapes that look like finder patterns. The generator tries all eight and keeps the one that scores best.
  6. Format and version information is written around the finder patterns.

Error correction levels

Reed-Solomon coding adds redundant data so that a scanner can rebuild missing or wrong codewords. There are four levels:

LevelRecovers aboutUse it for
L7 percentClean screens, maximum capacity, smallest code
M15 percentGeneral use
Q25 percentPrinted codes that may get worn
H30 percentHarsh conditions, or a logo placed over the code

Higher levels cost space. The same text needs more modules at H than at L. For example, https://gameparticles.com fits in a version 2 code (25 by 25) at level L but needs version 4 (33 by 33) at level H.

A logo in the middle of a QR code works only because of error correction. The logo destroys the modules beneath it, and the scanner rebuilds them. That is why codes with logos should use level H and keep the logo small.

How much a QR code can hold

Capacity in bytes, which is what ordinary text and URLs use:

VersionModules per sideLevel LLevel MLevel QLevel H
1211714117
22532262014
537106846044
1057271213151119
2097858666482382
401772,9532,3311,6631,273

The headline maximums for version 40 at level L are 7,089 digits, 4,296 alphanumeric characters or 2,953 bytes. In practice, keep content short. A URL under about 100 characters stays in the small versions that phones read instantly.

What the scanner does

A scanner runs the process in reverse. It finds the three finder patterns, straightens the perspective, reads the format information, samples each module, removes the mask and uses Reed-Solomon to fix errors. Then it decides what to do with the decoded text. A string starting with https:// opens in the browser. Prefixes such as WIFI:, mailto: and tel: trigger other actions.

That last step matters: a QR code itself is only text. There is no tracking and no expiry built into the pattern. See do QR codes expire for what that means in practice, and WiFi QR codes for an example of a special text format.

How to make a QR code

  1. Open the QR Code Generator and type or paste your content into the URL or Text box. The preview updates as you type, and a character count sits below the box.
  2. Choose the error correction level: L, M, Q or H. The generator starts on H. Switch to M for a simpler-looking code if you are not adding a logo.
  3. Pick a color preset or set your own Foreground and Background colors. Classic is black on white.
  4. Optionally change the Dot Style and Corner Style, or add a Center Logo and set its width and height. Adding a logo switches error correction to H.
  5. Click PNG or SVG to download, or Copy Image to put it on the clipboard.

Tips for codes that scan every time

  • Keep strong contrast, with a dark foreground on a light background. Some scanners struggle with inverted codes, where the modules are lighter than the background, so test the dark presets before using them in print.
  • Leave clear space around the code. The download has a narrow margin, so do not place text or borders tight against it.
  • Use SVG for print. It is a vector file and stays sharp at any size. The PNG is 520 by 520 pixels, which suits screens and small prints.

Try it

Paste a link into the QR Code Generator, switch between error correction levels to watch the pattern grow and shrink, then download the code as SVG for print or PNG for the web.

Tools in this guide

Frequently asked questions

How do I make a QR code?

Type or paste a URL or text into a QR code generator, choose an error correction level, and download the image as PNG or SVG. Test it with a phone camera before printing. A code made this way is static and keeps working indefinitely.

How much data can a QR code hold?

The largest QR code, version 40 at the lowest error correction level, holds 7,089 digits, 4,296 alphanumeric characters or 2,953 bytes. Practical codes hold far less, because small codes with large squares are much easier to scan.

What are the three squares in the corners of a QR code?

They are finder patterns. Their fixed shape lets a scanner locate the code, work out its size and rotation, and correct for a tilted camera. The fourth corner has no finder pattern, which tells the scanner which way is up.

Which QR code error correction level should I use?

Level M, about 15 percent recovery, suits most printed and on-screen codes. Use Q or H for codes that may get dirty or scratched, or that have a logo in the center. Use L when you need the smallest possible code.

More random & generators guides

JSON Formatter
Developer · Format, validate and minify JSON with syntax highlighting.
↵
Base64 Encode / Decode
Developer · Encode text to Base64 or decode Base64 back to plain text.
↵
URL Encoder / Decoder
Developer · Encode or decode URL components and query strings.
↵
Hash Generator
Developer · Generate MD5, SHA-1, SHA-256 and SHA-512 hashes.
↵
UUID Generator
Developer · Generate UUIDs v4 (random) in bulk with one click.
↵
Regex Tester
Developer · Test regular expressions against text with live match highlighting.
↵
Word Counter
Text · Count words, characters, sentences, paragraphs and reading time.
↵
Case Converter
Text · Convert text between UPPER, lower, Title, camelCase, snake_case and more.
↵
List Sorter
Text · Sort, reverse, deduplicate and shuffle lists of text.
↵
Markdown Preview
Text · Write Markdown and see a live rendered preview side by side.
↵
Percentage Calculator
Numbers · Calculate percentages, increases, decreases and what % one number is of another.
↵
Color Converter
Colors · Convert colors between HEX, RGB, HSL and HSV instantly.
↵
Snake
Arcade · Eat food, grow longer, don't hit the walls. A timeless classic.
↵
2048
Puzzle · Slide tiles and combine them to reach the legendary 2048 tile.
↵
Word Grid
Puzzle · Guess the hidden five letter word in six tries using color clues.
↵
Sudoku
Puzzle · Fill the 9x9 grid with logic. Four difficulties from easy to expert.
↵
Minesweeper
Strategy · Use number clues to clear the minefield. Classic logic, three levels.
↵
Breakout
Arcade · Smash every brick with paddle and ball. Power-ups, combos, endless levels.
↵
Typing Practice
Casual · Build your WPM and accuracy with timed drills from 30 seconds to 5 minutes. Find your weak keys.
↵
TypeRunner
Arcade · Multiplayer typing race. Race friends by link, beat computer runners, or chase your own ghost.
↵
Typing Blocks
Arcade · Type each word before its wooden block lands. Miss, and the pile climbs toward the line.
↵
Bubble Shooter
Arcade · Aim, bank shots off the walls, and pop groups of three or more bubbles.
↵
Road Rush
Arcade · Race seven rivals through traffic and punch your way to the front.
↵