
White-on-black QR codes look good on a dark poster, a black T-shirt or a dark-mode screen. Many designers just swap the two colours and move on. But does the code still scan? A QR code is defined as dark squares on a light background, and some readers only look for that. So we tried it.
We made 160 QR codes (40 links of 23 to 150 characters, each at all four error correction levels), drew every one twice, once normal and once with the colours swapped, and read each picture with three open-source readers, with their "try the inverted image" switch on and off. That was 3,200 reads. The result: <strong>OpenCV read none of the 160 inverted codes, ZXing read all 160 but only because its invert switch was on, and jsQR read all 160 sharp ones but missed 15 of the phone-like ones.</strong> Normal codes were read almost every time by all of them.
How we tested
- Links: 40 made-up links of 23 to 150 characters on four hostnames (b59.link, example.com and two others), fixed random seed. Python
qrcodeat the smallest version that fits (versions 2 to 12), 4-square quiet zone. - Inverted: the same picture with every pixel flipped: light squares on black, and the quiet zone black too. Nothing else changed.
- Two conditions: sharp (10 pixels per square) and phone-like (shrunk to 240 × 240 pixels with a 0.8-pixel blur).
- Readers: OpenCV 4.11 QRCodeDetector (it has no invert option), ZXing-C++ via
zxing-cppwithtry_inverton and off, and jsQR withattemptBothanddontInvert. - A read counts only if the text matches the link exactly.
Results: how many of 160 codes each reader got
| Reader and setting | Normal, sharp | Inverted, sharp | Normal, phone-like | Inverted, phone-like |
|---|---|---|---|---|
| OpenCV QRCodeDetector (no switch) | 154 / 160 * | 0 / 160 | 157 / 160 | 0 / 160 |
ZXing-C++, try_invert on (default) | 160 / 160 | 160 / 160 | 160 / 160 | 160 / 160 |
ZXing-C++, try_invert off | 160 / 160 | 0 / 160 | 160 / 160 | 0 / 160 |
jsQR, attemptBoth (default) | 160 / 160 | 160 / 160 | 159 / 160 | 145 / 160 |
jsQR, dontInvert | 160 / 160 | 0 / 160 | 159 / 160 | 0 / 160 |
* OpenCV missed 6 of the 160 normal sharp codes and 3 of the phone-like ones, mostly dense codes for long links, so it isn't a perfect reader even on ordinary codes.

Where jsQR dropped codes
jsQR with its default setting read every sharp inverted code, but in the phone-like condition it lost 15 of 160. All 15 were dense codes (versions 9 and 10, which means links of 95 characters and more at levels Q and H). The same links drawn normally lost 1. So inverted codes for short links were fine, and the longer the link, the more it hurt:
| Link length | Inverted codes | ZXing, invert on | jsQR, invert on | Any reader, invert off |
|---|---|---|---|---|
| 23-60 characters | 48 | 48 / 48 | 48 / 48 | 0 / 48 |
| 61-100 characters | 48 | 48 / 48 | 47 / 48 | 0 / 48 |
| 101-150 characters | 64 | 64 / 64 | 50 / 64 | 0 / 64 |
What to do with a light-on-dark code
- If you can, print dark on light. Every reader we tried read nearly all normal codes. A dark or coloured background is fine as long as the code itself is a dark pattern on a light patch; our colour and contrast test covers how much colour is safe.
- If you must invert, use a short link. A short link makes a small, sparse code, and every reader with an invert setting read all of those. You can also change where it points after printing.
- Print a test. Scan the printed code with a phone camera and at least one other scanner app before you order a batch. We only tested open-source readers, not the camera apps built into phones; some of those read inverted codes and some may not.
- Check library defaults. If you scan codes in your own app or website and want inverted ones to work, make sure the invert option is on. OpenCV's detector had none.
Limits of this test: pictures drawn on screen, not printed and photographed; plain black and white only; three readers. Phone camera apps use their own decoders, which we didn't test.
Make the code
Our free <a href="/tools/qr">QR code generator</a> makes dark-on-light codes with the error correction level and colours you choose, as PNG or SVG. Point it at a <a href="/">b59.link short link</a> to keep the code small and count scans. For size and distance see <a href="/articles/print-qr-code-size-scan-distance">printing a QR code that scans</a>, and for logos <a href="/articles/qr-code-logo-placement-centre-corner-test">where a logo can sit</a>.




