QR Codes

You can create a QR code on the fly with a URL GET request.

Overview

QR codes are a popular type of two-dimensional barcode. They are also known as hardlinks or physical world hyperlinks. QR Codes store up to 4,296 alphanumeric characters of arbitrary text. This text can be anything, for example URL, contact information, a telephone number, even a poem! QR codes can be read by an optical device with the appropriate software. Such devices range from dedicated QR code readers to mobile phones.

Syntax

Root URL: https://chart.googleapis.com/chart?

QR code requests support the following URL query parameters after the ? in the root URL:

Parameter Required or Optional Description
cht=qr Required Specifies a QR code.
chs=<width>x<height> Required Image size.
chl=<data> Required The data to encode. Data can be digits (0-9), alphanumeric characters, binary bytes of data, or Kanji. You cannot mix data types within a QR code. The data must be UTF-8 URL-encoded. Note that URLs have a 2K maximum length, so if you want to encode more than 2K bytes (minus the other URL characters), you will have to send your data using POST.
choe=<output_encoding> Optional How to encode the data in the QR code. Here are the available values:
  • UTF-8 [Default]
  • Shift_JIS
  • ISO-8859-1
chld=<error_correction_level>|<margin> Optional
  • error_correction_level - QR codes support four levels of error correction to enable recovery of missing, misread, or obscured data. Greater redundancy is achieved at the cost of being able to store less data. See the appendix for details. Here are the supported values:
    • L - [Default] Allows recovery of up to 7% data loss
    • M - Allows recovery of up to 15% data loss
    • Q - Allows recovery of up to 25% data loss
    • H - Allows recovery of up to 30% data loss
  • margin - The width of the white border around the data portion of the code. This is in rows, not in pixels. (See below to learn what rows are in a QR code.) The default value is 4.

 

Example:

QR code
cht=qr
chl=Hello+world
choe=UTF-8

QR Code Details [Optional Reading]

Here is a little more about how QR codes work; you don't necessarily need to know this to be able to generate a QR code.

QR codes are squares, with an equal number of rows and columns. There are a fixed set of QR code sizes: from 21 to 177 rows/columns, increasing in steps of four. Each configuration is called a version. The more rows/columns, the more data the code can store. Here is a summary of the versions:

  • Version 1 has 21 rows and 21 columns, and can encode up to 25 alphanumeric characters
  • Version 2 has 25 rows and 25 columns, and can encode up to 47 alphanumeric characters
  • Version 3 has 29 rows and 29 columns, and can encode up to 77 alphanumeric characters
  • ...
  • Version 40 has 177 rows and 177 columns, and can encode up to 4,296 alphanumeric characters

Don't confuse the number of rows and columns with size of the QR code image. The pixel size of the code is determined using chs as usual.

The API will determine which version to use, based on the amount of data you provide.

The appropriate QR code version will be returned depending on the number of characters you provide. For example, if you provide 55 alphanumeric characters, you will get a Version 3 QR code, although this can change if you specify an error correction (EC) level explicitly using the chld parameter.

Before generating your QR code, consider what kind of device is used to read your code: the best QR code readers are able to read Version 40 codes; mobile devices might only be able to read up to Version 4.

The following table summarizes the characteristics of a few different versions:

Version Rows x Columns EC level Maximum characters by EC level and character type
Digits: 0 to 9 Alphanumeric:
0 to 9, A to Z,
space, $ % * + - . / :
Binary Kanji
1 21x21 L 41 25 17 10
M 34 20 14 8
Q 27 16 11 7
H 17 10 7 4
2 25x25 L 77 47 32 20
M 63 38 26 16
Q 48 29 20 12
H 34 20 14 8
3 29x29 L 127 77 53 32
M 101 61 42 26
Q 77 47 32 20
H 58 35 24 15
4 33x33 L 187 114 78 48
M 149 90 62 38
Q 111 67 46 28
H 82 50 34 21
10 57x57 L 652 395 271 167
M 513 311 213 131
Q 364 221 151 93
H 288 174 119 74
40 177x177 L 7,089 4,296 2,953 1,817
M 5,596 3,391 2,331 1,435
Q 3,993 2,420 1,663 1,024
H 3,057 1,852 1,273 784

Further Information and Standards

The QR code standard is trademarked by Denso Wave, Inc.

The ISO sells the English language specification on their site. The Japanese version is free.

QR code standards are approved as:

  • AIM International (Automatic Identification Manufacturers International) standard (ISS - QR Code) in October 1997.
  • JEIDA (Japanese Electronic Industry Development Association) standard (JEIDA-55) in March 1998.
  • JIS (Japanese Industrial Standards) standard (JIS X 0510) in January 1999.
  • ISO international standard (ISO/IEC18004) in June 2000.

QR code reader software is available from many sources. Google offers a QR Code reader library, Zebra Crossing (ZXing), for free. See http://code.google.com/p/zxing/ for details.

See Barcode Contents for a rough guide to standard encoding of information in barcodes