What Is a QR Code and How Does It Work?

A QR code ("Quick Response" code) is a square, two-dimensional barcode that stores information such as a web address, a WiFi login or a contact card. Point your phone's camera at it and the phone decodes the pattern and offers to open the link or save the data. QR codes were invented in 1994 by Masahiro Hara at Denso Wave, a Toyota supplier, to track car parts on the production line. Today they are everywhere: restaurant menus, payment terminals, train tickets, product packaging and business cards.

How is a QR code different from a normal barcode?

A traditional barcode, like the one on a cereal box, is one-dimensional. It stores data in the widths of vertical lines and typically holds only 12 to 13 digits. A QR code stores data both horizontally and vertically, so it can hold far more: up to 4,296 letters and numbers or 7,089 digits in the largest version. It can also be read from any angle, which is why you do not need to line your phone up carefully.

The parts of a QR code

  • Finder patterns: the three large squares in the corners. They tell the scanner where the code is and which way up it is.
  • Alignment patterns: smaller squares (in larger codes) that help correct for a curved or tilted surface.
  • Timing patterns: alternating dark and light lines between the finder patterns that set the grid size.
  • Format and version information: small areas next to the finders that record the error correction level and size.
  • Data and error correction modules: everything else, the actual encoded content plus backup data.
  • Quiet zone: the empty margin around the code. Scanners need it to find the edges, so never crop it off.

Versions: why some QR codes look busier

QR codes come in 40 sizes called versions. Version 1 is a 21 × 21 grid of squares ("modules"), and each version adds 4 modules per side, up to 177 × 177 for version 40. The more data you put in, the higher the version and the denser the pattern. A short URL usually fits in version 2 to 4, which is easy to scan even when printed small. This is why short links are better than long ones with lots of tracking parameters.

Error correction: how a QR code survives damage

QR codes use Reed-Solomon error correction, the same mathematics used on CDs and in satellite communication. Extra data is added so that the code can still be read if part of it is dirty, scratched or covered. There are four levels:

LevelData that can be restoredBest for
L (Low)about 7%Clean screens, maximum data
M (Medium)about 15%Everyday use (our default)
Q (Quartile)about 25%Outdoor signs, packaging
H (High)about 30%Codes with a logo, harsh environments

Higher error correction makes the code denser, so choose the lowest level that suits the situation. When you add a logo with our QR code generator, we switch to level H automatically because the logo covers part of the data.

What can a QR code contain?

Technically a QR code just stores text. Phones recognise special formats in that text and act on them:

  • https://... opens a website
  • WIFI:T:WPA;S:name;P:password;; joins a WiFi network (see our WiFi QR code generator)
  • BEGIN:VCARD... saves a contact (see the vCard generator)
  • tel: starts a phone call
  • geo:3.1579,101.7116 opens a map location

How your phone reads a QR code

The camera finds the three finder squares, works out the angle and size, and samples each module as dark or light. It reads the format information, removes a mask pattern (applied to avoid large blank areas), and decodes the data, using error correction to fix any unreadable parts. All of this takes a fraction of a second. Since 2017 the built-in camera apps on iPhone and most Android phones do this without any extra app.

Are QR codes safe?

A QR code itself cannot harm your phone. It is only a way to deliver text or a link. The risk is where the link goes. Criminals sometimes place fake QR code stickers on parking meters or posters to send people to phishing sites. Always look at the web address your phone shows before you open it, and be careful with any page that asks for a password or payment. You can also check a code safely with our online QR scanner.

Ready to make one? Create a free QR code with your own colours and logo on the QR code generator.