How to Generate a Styled QR Code with Custom Colors (No Third-Party Host)
Plain black-and-white QR squares often look out of place on posters and cards. Can you use brand colors and softer module shapes? Yes—within hard limits: the three finders and the error-correction budget.
How far QR design can go
A QR works through three finder patterns and Reed–Solomon correction. Inside those constraints you can restyle:
| Safer to change | High risk |
|---|---|
| Foreground/background color (luminance contrast) | Covered or heavily warped finders |
| Eye and dot styles (this site's designer) | Quiet zone eaten by artwork |
| Center logo composited after export | Oversized logo on alignment patterns |
| Size and margin | Inverted or low-contrast gradients |
Error correction
| Level | Approx. recoverable | Use |
|---|---|---|
| L | ~7% | Clean screens |
| M | ~15% | Default here |
| Q | ~25% | Light planned cover |
| H | ~30% | Larger center mark / outdoor |
Planning a center mark → pick Q or H, keep cover modest, and still real-scan.
Implementation notes
The QR code designer also uses qrcode (^1.5.4), then restyles modules on a Canvas:
| Item | Behavior on this site |
|---|---|
| Base draw | QRCode.toCanvas (colors, size, margin, ECC) |
| Eyes | square / circle / rounded |
| Dots | square / circle / dots / star |
| Size | 128–512 px, step 32 |
| Margin | 0–8 modules |
| Logo | No upload/embed—composite in a design tool after export |
| Contrast meter | Live WCAG-style luminance ratio; <2.5 fails, <4.5 warns, ≥4.5 OK |
| PNG export | Includes the styled Canvas (custom eyes/dots) |
| SVG export | QRCode.toString({ type: 'svg' })—standard square modules + colors only; no custom eyes/dots/stars |
Fast monochrome PNG → QR generator. Round-trip → QR decoder. Long links → URL encoder and URL encoding guide; Base64 payloads → Base64 guide. Pair brand colors with the contrast checker when you need WCAG text ratios as well.
Step-by-step
- Open the QR code designer.
- Enter a URL, text, or
WIFI:/ vCard string. - If you will add a center mark later, set ECC to Q or H and keep content short.
- Tune colors, eye/dot styles, and margin; preview updates live. Watch the contrast line under the controls — fix red/amber before you download.
- Real-scan on a phone; then download PNG (or SVG if you accept standard square modules for print vectors).
- For a logo: place the PNG/SVG in Figma/print software, overlay a transparent mark (often ~15–20% of the code area), and scan again.
Plain black/white → generator. Read an existing image → decoder.
Design principles
- Luminance contrast first: scanners binarize. Vivid hue with similar lightness fails. The designer reports the ratio live; dark-on-light remains the durable default.
- Quiet zone: about four modules of clear border; do not crop it in the layout. Margin
0is a trap for print crops. - Logo budget: you spend ECC headroom. H’s ~30% is a ceiling; working practice often stays near 15–20% center cover. Soft gradient logos bleed into modules—hard edges scan cleaner.
- Fancier styles need more testing:
star/ thindotsshrink effective ink; at small print sizes, simplify or enlarge. - SVG is not WYSIWYG for styles: custom eyes/dots exist on PNG preview/download; SVG is the library’s standard matrix.
Capacity, density, and URLs
Versions 1–40 trade against ECC and length: long UTM URLs at H → high version → dense modules → small print fails. Practical breakpoint: under ~60 characters at Q often works near 2 cm on a card; the same payload at 1.2 cm with H fails on cheap cameras.
| Payload shape | Typical outcome |
|---|---|
| Short HTTPS path (<40 chars) + M/Q | Friendly for business cards |
| Long UTM query + H | Dense; enlarge print or shorten |
| Full JSON / long Base64 | Wrong medium — use a short link |
| CJK URL without shortening | Percent-encoding bloat — see Chinese percent-encoding |
Shorten before styling—put tracking on the landing page.
Static vs dynamic
The designer emits a static pattern: payload baked in, no server, immutable after print. Campaigns often use a redirect layer (dynamic): the pattern points at a short link you control. Long-lived print usually encodes your domain’s redirect, then changes the target without reprinting.
Print and viewing distance
| Use | Rough minimum side length | Notes |
|---|---|---|
| Business card | ~2 cm | Prefer square dots / higher contrast |
| A5 flyer | ~3–4 cm | Leave quiet zone outside ink bleed |
| Banner viewed at 1 m | ~10 cm | Screen preview ≠ outdoor glare |
Rule of thumb: minimum side length roughly ≥ 1/10 of scan distance. Always print a proof — phone screens hide ink spread and paper texture.
Scan test checklist
| Check | Pass bar |
|---|---|
| iPhone camera | Stable detect |
| Android camera | Same |
| WeChat scan (CN materials) | Recommended gate |
| Distance / lighting | Real viewing conditions |
| Print proof | Screen ≠ ink |
| After logo overlay | Re-scan; if flaky, raise ECC or shrink logo |
Common use cases
- Wi‑Fi:
WIFI:T:WPA;S:name;P:password;;— keep SSID/password short; fancy dots + long password densifies the matrix - vCard: scan to save a contact — put a short landing URL if the card is dense
- Event print: white underlay when the poster background is busy
- Packaging: short link to docs/registration
FAQ
Q: Colored QR won't scan?
Usually luminance contrast or disturbed finders. Restore high-contrast solids first (clear the designer’s fail/warn state), then restyle.
Q: Can I upload a logo here?
No. The designer handles color and module style; composite logos externally and verify by scan.
Q: Why are dots round in preview but square in SVG?
SVG comes from qrcode's standard vector path—no Canvas restyling. Keep custom shapes via PNG, or redraw in a vector tool.
Q: Capacity limits?
Yes. Version 40 at high ECC is far below the “7000+ digits” headline for real text. Do not stuff documents—use a short link.
Q: Do codes expire?
Patterns do not; URLs / Wi‑Fi / campaign pages do. Prefer a mutable redirect for long-lived print.
Q: Dark mode / inverted brand colors?
Light modules on a dark field can work if the luminance ratio clears ~4.5:1 and finders stay intact — but many consumer apps assume dark-on-light. Prefer dark modules on light when the audience is mixed.
Summary
Scannable style = enough ECC + enough luminance contrast + modest center cover + real-device tests. Style locally in the QR designer; add logos outside; scan before you ship.
Written and maintained by ToolVault. More developer tools at the homepage.
Related Tools
Related Articles
China License Plate Rules and Validation: Standard, New Energy, and Special Formats Explained
Mainland China plate encoding rules in full: the standard blue plate, the GA36D-2018 new-energy format, armed police and embassy plates, province abbreviations and issuing-authority letters — with an online validator.
HTTP Status Codes Reference: Quick Lookup Guide
Complete HTTP status code reference. Understand 1xx, 2xx, 3xx, 4xx, 5xx categories, common scenarios, and correct usage in API development.
What Is GEO? Generative Engine Optimization: The New Traffic Frontier of AI Search
GEO (Generative Engine Optimization) is to AI search what SEO is to Google — when ChatGPT, Perplexity, and Google's AI Overviews answer questions directly, users stop clicking links, and being cited by AI becomes the new traffic entry. This post breaks down the four essential differences from SEO, the four core practices (crawlability, structure, citability, fact density), and real GEO data from a working tool site.