QR codes: a practical guide to generating and decoding them locally
A QR code is just data drawn as black and white squares. Here is how to encode the right thing, choose a correction level, print it so it scans, and read it back from a screenshot — all in your browser.
A QR code looks like random noise, but it is a very deliberate piece of engineering. The black and white squares — called modules — are not decoration: they are the data, written in two directions so a phone can read the message even when the code is turned, tilted, or partly dirty. Understanding what is inside the pattern makes it much easier to generate one that scans reliably and to understand why a code sometimes refuses to be read.
How a QR code stores data
Think of a QR code as a grid of tiny black and white tiles. Each tile is one bit: dark means one value, light means the other. The three large square finders in the corners tell a scanner where the code begins and ends and which way up it is. The rest of the grid carries your actual payload — a URL, a sentence, a WiFi credential — together with the error-correction data that protects it.
Because the payload is written into the pattern itself, a QR code has no moving parts and no account behind it. A scanner does not contact any service to find out what the code means; it simply reads the black and white tiles and reconstructs the original string. That is why a printed code can keep working for years, and why the content is exactly what you typed.
Error correction: L, M, Q and H
Here is the part that surprises most people: a QR code deliberately wastes space. Alongside your data it stores redundant data, so that if part of the pattern is unreadable, the missing pieces can still be reconstructed. This is called the error-correction level, and the generator offers four choices.
- L — about 7% recovery. The least dense pattern. Use it for large, clean codes shown on a screen, where nothing will damage them.
- M — about 15%. The default, a good balance for everyday printing and sharing.
- Q — about 25%. For codes that will be small, folded, or partly covered.
- H — about 30%. The most damage-tolerant. The right choice for outdoor signs, product labels, and anything printed small.
The trade-off is simple: the higher the level, the more redundant modules the pattern needs, and the denser it becomes. A denser code has smaller individual squares at a given print size, which are harder for a camera to resolve at a distance. So "more correction" is not always better — pick the lowest level that still survives where the code will live. The default M is fine for most uses; step up to H when the code will be dirty, small, or exposed.
Generating a code: URLs, text and WiFi
The content you type is encoded verbatim, so the generator accepts the usual payloads:
- A URL — the most common case. The full address, including https://, is what gets encoded.
- Plain text — a message, an ID, a serial number, a short note.
- WiFi details — entered as a formatted text string such as WIFI:T:WPA;S:NetworkName;P:password;; which phones recognise as a network to join.
QR code generator lets you set the error-correction level and the output size (300 to 2048 pixels), pick the foreground and background colours, and download the result as PNG or SVG. Keep the payload as short as you can: the more characters you encode, the more modules the grid needs, and the smaller each module becomes at a fixed size. A short link or a short ID scans more easily than a long paragraph.
Size, contrast and printing
A QR code is read by a camera, so it obeys the rules of optics rather than aesthetics. Two things matter most: enough physical size and enough contrast.
- Dark modules on a light background is the most reliable combination. Dark-on-light also survives poor lighting better than an inverted scheme; some scanners cannot read inverted codes at all.
- Leave the quiet zone intact. The blank margin around the pattern is part of the specification — the generator keeps a four-module border. Do not crop it away or print artwork into it.
- Mind the physical size. For printing, aim for an edge of at least 2 cm (about 0.8 inch), and more if the code will be scanned from a distance. A 600-pixel PNG is plenty for a screen; for print, download the SVG and let the printer scale it without pixelation.
- Do not stretch it. Keep the code square. Non-uniform scaling distorts the modules and can break decoding.
When in doubt, make the code bigger and keep the colours simple. A slightly larger black-and-white code almost always beats a small, low-contrast, or multi-coloured one.
Reading a code from a screenshot or photo
Decoding is the reverse operation: point a camera at the pattern, or load an image that already contains one, and the software reads the modules back into a string. QR code reader takes a screenshot or photo, decodes it locally with jsQR, and shows the content so you can copy it. It reads the clearest single code in an image — for several codes, save each as its own image and decode them one at a time.
A clean screenshot is the easiest input of all: the modules are perfectly sharp, square, and evenly lit. A photo works too, provided the code is large enough in the frame and reasonably straight-on.
When decoding fails
Decoding fails when the camera cannot reliably tell dark modules from light ones. The usual causes are:
- Blur or low resolution — the module edges smear together, so the grid can no longer be sampled.
- Glare and reflections — a bright hotspot washes out the dark squares, destroying the contrast the decoder needs.
- Strong tilt or perspective — severe angles turn squares into slivers; mild rotation is fine, extreme perspective is not.
- Cropping or obstruction — if a finder pattern or too much of the grid is cut off, there is nothing to align on.
- Several codes at once — the decoder picks the clearest single code, so isolate the one you want before decoding.
And a limit worth stating plainly: error correction can replace a modest number of damaged modules, not reconstruct a severely destroyed code. A torn, half-missing, or heavily scribbled-on pattern may simply be unreadable.
Privacy: the message is in the pattern
Because the content is encoded directly in the black and white modules, a QR code does not depend on a short-link service and does not report scan statistics back to anyone. Generating one writes your string into an image; reading one reads that string back. Both QR code generator and QR code reader run in your browser, so the text you generate and the image you decode stay on your device. A WiFi password in a code is no different: it travels as part of the pattern, not through a server.
Two common misconceptions
- "QR codes expire." The pattern itself never expires — it is just a picture of your data. What can expire is the thing it points to: a link that is taken down, a short URL that is discontinued, or an offer that ends. If the destination stays alive, the code keeps working.
- "You can drop a logo in the middle." Only with care. The centre of a QR code carries data, and error correction is what lets you cover some of it. If you add a logo, keep it small, keep the area around it clear, and use a higher correction level (Q or H) so the covered modules can be recovered. Test the result by scanning it before you print it.
Generate with enough correction and contrast, decode from a clean image, and a QR code is one of the most durable ways to move a short piece of information from a screen into the physical world.
Frequently asked
Do QR codes expire?
No. The pattern is just your data encoded as an image, so it has no expiry date. What can stop working is the destination — a link that goes offline or an offer that ends. If the target stays live, the code keeps working.
Will my text or image be uploaded?
No. Both generation and decoding run in your browser. The text you encode and the image you decode stay on your device.
Can I decode several QR codes in one image?
The decoder reads the clearest single code in an image. If a picture contains several codes, save each one as its own image and decode them one at a time.
Why can’t my phone scan a code I generated?
Usually contrast or size. Use dark modules on a light background, keep the blank quiet zone, and print an edge of at least 2 cm. For small or outdoor codes, choose a higher error-correction level.
Can I put a logo in the middle?
Yes, but keep it small and use a higher correction level such as Q or H so the covered modules can be recovered. Leave the area around the logo clear, and scan the result before you print it.