Back to blog
  • QR code
  • free tools
  • design

Custom QR code with logo: guide and free generator

How to make a custom QR code with colors and a logo that actually scans: contrast, error correction, printing and a free generator that runs in your browser.

By Alessio Ferraro9 min read
Quash, the Hash42 quokka mascot, in sunglasses and an orange hoodie giving a thumbs up and holding a phone with a colorful QR code and the H42 logo in the center, on a peach background, under the title The best free online QR code generator
In this article

A black and white QR code almost always works. Trouble starts when you want to customize it: brand colors, a gradient, a logo in the middle, rounded dots.

Every design choice takes away a little of the margin the phone's reader relies on. Done well, the QR code stays readable and becomes recognizable. Done badly, the code printed on a thousand flyers will not open.

This guide covers what makes a custom QR code unreadable, how error correction works, how to create one with colors and a logo in a free generator and, for developers, how that generator is built.

Why a custom QR code stops working

A phone reads a QR code by telling dark modules from light ones, the small squares that make up the code. Anything that blurs that difference, or covers part of the modules, makes it harder to read.

Low contrast. This is the most common cause. Orange on yellow or gray on white can look elegant, but to the camera they are almost the same color. The code has to be much darker than the background, or much lighter.

Light colors on a light background. A special case of the previous one, but a frequent one: pastel on white, pale gold on cream. The code should be dark and the background light. Many recent phones can read light codes on a dark background, but that is the riskiest choice and always needs testing.

Gradients. A gradient is fine as long as both colors contrast with the background. What matters is the weakest point: if one end of the gradient is light, that part of the code reads poorly.

A logo that is too big. A logo in the center covers some of the modules. The code survives thanks to error correction, which has a limit.

No margin. A QR code needs empty space around it, called the quiet zone. The standard calls for 4 modules on each side. A code printed flush against a photo or a colored border loses that margin, and the phone struggles to find where it starts.

Unrecognizable corners. The three large squares in the corners help the phone find the code and orient it. You can round them, but they have to stay three clearly visible squares.

Error correction: L, M, Q and H made simple

A QR code holds more information than it strictly needs. Part of the data is repeated as correction codes: if the code is dirty, damaged or partly covered, the phone rebuilds what is missing.

There are four levels. Each one says roughly how much of the code can be recovered:

  • L: about 7%;
  • M: about 15%;
  • Q: about 25%;
  • H: about 30%.

The higher the level, the more spare data it needs. For the same content, a level H code has more modules, so at the same printed size each module is smaller.

With a logo in the center you need level H. The logo erases some modules, and error correction has to make up for them.

That 30% is not a target, though. It is the whole reserve, and it also has to cover glare, folds, dirt and blurry photos. A logo that pushes the limit leaves the code with no margin for anything else, so stay well below it.

How to create a QR code with a logo and colors

Here are the steps with QR Generator. The ideas apply to any generator.

1. Choose the content type. There are eight types: URL, text, WhatsApp, email, phone, Google Maps, Wi-Fi and business card (vCard). For Wi-Fi, enter the network name, the password and the security type (WPA, WEP or open network): whoever scans the code joins without typing anything. If the network name or password contains special characters such as semicolons or quotes, the generator formats them correctly.

2. Start from a preset. Six ready-made styles give you a base: Hash42, Minimal, Premium, Restaurant, Business and Cyberpunk. If you create a combination you like, you can save it as your own preset and find it again next time.

3. Pick dots and corners. Dots come in six styles: Square, Rounded, Extra Rounded, Dots, Classy and Classy+. Corners in three: Square, Rounded and Circular.

4. Set the colors. Choose the QR color and the background color, from a palette of quick colors or with the color picker. You can turn on a two-color linear or radial gradient.

5. Add the logo. Upload a PNG, SVG or WEBP file up to 500 KB. You can adjust the logo size, the space around it and, if the logo needs a backdrop, the color of a rounded tile behind it. When you upload a logo, error correction switches to level H on its own.

6. Check the scannability score. Below the preview there is a score from 0 to 100 with warnings: low or borderline contrast, gradients included, a logo that is too big, error correction that does not suit the logo. It checks the rules above, it is not a scan test: the real test is still pointing a phone at the code.

7. Download. The formats are PNG, SVG and WEBP, at 512, 1024 or 2048 pixels. The downloaded file is identical to the preview. For print, SVG is the best choice because it stays sharp at any size; for the web and social media, PNG or WEBP are fine.

The file comes without a border around the code: when you place it on a flyer or a menu, leave the quiet zone of at least 4 modules yourself.

Your latest downloaded codes and your own presets are saved in the browser you are using. The QR content and the logo are not sent to a server. On a phone the preview sits at the top and, as you scroll down to the controls, a thumbnail stays visible in a corner, so you see the effect of every change right away.

QR Generator in action: presets, colors, gradient and logo.

How it is built: a QR code generator in the browser

This part is for developers. QR Generator is a Next.js page with a single client component and no server call to create the code.

The library loads only when needed

The drawing is handled by qr-code-styling, an open-source library that supports dot styles, gradients and a center image. It is loaded with a dynamic import, await import("qr-code-styling"), on the first generation, so it does not weigh on the initial page load. The code comes out as an image through getRawData, which returns a PNG, SVG or WEBP file without going through a server.

One function for preview and download

The classic problem with these tools is a downloaded file that differs from the preview: a lost color, a shifted logo, a gradient missing from the SVG. Here the library options come from a single function, used both for the preview and for downloads in every format. Only the size changes.

function buildQrOptions(data: string, config: QRConfig, size: number, image?: string) {
  const options: Record<string, unknown> = {
    width: size,
    height: size,
    data,
    // ... colors, gradient, dot and corner styles
    backgroundOptions: { color: config.bgColor },
    qrOptions: { errorCorrectionLevel: config.errorCorrection },
  };
  if (image) {
    options.image = image;
    options.imageOptions = {
      margin: config.logoPadding,
      imageSize: config.logoSize,
      crossOrigin: "anonymous",
      hideBackgroundDots: true,
    };
  }
  return options;
}

hideBackgroundDots removes the modules under the logo instead of drawing on top of them: the logo stays clean and error correction knows those modules are missing.

The library has no option for a logo backdrop. When you pick one, the logo is drawn on a rounded tile in a canvas and handed to the library as a ready-made image.

Debounced regeneration

Every change, a color or a typed character, changes the code. Regenerating it on every keystroke would be wasteful, so there is a debounce: each change resets a timer, and generation starts only 300 milliseconds after the last one.

Each generation also gets a sequence number. If a result arrives late, after a newer change, it is discarded: the preview always shows the latest version.

The scannability score

The score starts at 100 and drops according to simple rules:

  • the contrast between code and background uses the relative luminance formula from the WCAG guidelines; with a gradient, the color with the lowest contrast counts;
  • below 3:1 the score loses 40 points, between 3:1 and 4.5:1 it loses 15;
  • a logo larger than 0.35 (the size slider goes from 0.1 to 0.4) takes away 25;
  • a logo without level H correction takes away another 10.

Wi-Fi and business cards

Wi-Fi QR codes use a text format read by Android and iPhone, like WIFI:T:WPA;S:name;P:password;;. Semicolons, commas, colons, quotes and backslashes mean something in that format, so in the network name and password they must be preceded by a backslash. The same goes for vCard 3.0 business cards, where commas, semicolons and line breaks have to be escaped. Without this step, a password with a semicolon produces a code that looks right but does not connect.

Checklist before printing a QR code

A printed QR code lives a long time, and a mistake shows up when it is too late. It is also worth thinking about where it leads: a link to a page you control that will stay online. A restaurant, for example, is better off pointing to a digital menu that it can update, such as those made with Manji, than to a PDF that changes name every season.

A code made with a generator like this one is static: it contains the link directly and never expires. Dynamic generators go through an intermediate address of their own, and if the service shuts down or the subscription ends, the code stops working.

Before sending it to print, check at least these points:

  • The code is dark on a light background, with a contrast of at least 4.5:1, including the lightest part of any gradient.
  • With a logo, error correction is H and the logo stays well below the limit.
  • There are at least 4 modules of empty space around the code.
  • The code is at least 2 cm wide for a short link, and for scanning from afar about one tenth of the distance.
  • You have tested it with at least two different phones, at its final size.
  • The link leads to a page you control that will not expire.

If you need other free tools for images, colors and logos, they are all on tools.hash42.xyz. The guide to 5 free tools for images, colors and QR codes gives an overview of each one.

Sources

Share
Alessio Ferraro

Written by

Alessio Ferraro

Founder & Build Leader

meet al33xf

Have a project in mind?

Hash42 Labs designs and builds web apps, websites and digital products for businesses, with security built in from day one. The same principles behind this article power Manji and Muni.