SVG codes have visible banding on iOS

Author: cmbartschatCreated Aug 2, 2021Updated Aug 1, 2025

Viewing an SVG code on iOS 14 or 15 in Safari that was generated with: qrcode.toString(url, {type: 'svg'}), gives the following:

Zoomed in screenshot of a QR code showing horizontal bands between rows of modules

I'm not sure if this should be considered a rendering bug in WebKit, it might be worth opening an issue with them, but since there are devices in the wild that exhibit this, I opted to ship a workaround for now.

What I did was increase the height of each module by 2% so they overlap slightly, enough to ensure continuous fill, by adding stroke-width="1.02":

Zoomed in screenshot of a QR code showing no banding, but slight overlap at the corners of modules

If the QR codes are viewed at reasonably small sizes, the change isn't noticeable, but it does add slight overlap.

I see there was discussion here about potentially using <rect> instead of a stroke, maybe using <rect> avoids this issue if that's a direction the maintainers are interested in going.