Skip to main content

QR Code API

QuickChart supports QR code generation. Generate a QR code like this:

https://quickchart.io/qr?text=Here's my text

QR code parameters

Build your customized QR code using the following query parameters. You may also use the web-based QR code builder.

Parameter NameDescriptionRequired?Default value
textContent of the QR code (can be a URL or any other string)Yes
formatFormat of QR code, either png, svg, or base64png
marginWhitespace around QR image4
sizeWidth and height dimension of the image150
darkHex color code of "dark" QR grid cells000000 (black)
lightHex color code of "light" QR grid cellsffffff (white)
ecLevelError correction level (L, M, Q, H)M (H if center image is present)
centerImageUrlURL of image to show in the center. Must be URL-encoded.
centerImageSizeRatioHow much space to take up, between 0.0 and 1.00.3
centerImageWidthWidth of center image in pixels
centerImageHeightHeight of center image in pixels
captionCaption text to display below the QR code.
captionFontFamilyFont family of the caption text'sans-serif'
captionFontSizeFont size of the caption text in pixels.10
captionFontColorColor caption text, color names or hex code.black
tip

Remember to URL-encode the text parameter. Otherwise special characters and symbols might not be included correctly (the QR builder takes care of this automatically).

Customizing QR code appearance

To customize the color of your QR code, use dark and light. The parameters must be hex color codes (e.g. dark=000000, light=ffffff). For a transparent background, set light to 0000.

Set the whitespace around QR image in modules with query parameter margin (defaults to 4), size determines the pixel dimensions of the image (defaults to 150), and error correction level with ecLevel (valid values: L, M, Q, H).

The QR endpoint produces a PNG image by default. You may optionally set the query parameter format=svg for SVG format.

Here's the same code as above but URL encoded with slimmer margins, more error protection, colors, and in SVG format:

https://quickchart.io/qr?text=Here's%20my%20text&dark=f00&light=0ff&ecLevel=Q&format=svg

Use our interactive QR code generator to preview API behavior and test things out. You may also be interested in how to generate QR codes in a spreadsheet.

Images in QR codes

You may include an image centered in your QR code by using the centerImageUrl parameter. Note that the URL must be URL-encoded. PNG and JPG images are supported.

For example:

https://quickchart.io/qr?text=Here's my text&centerImageUrl=https://cdn-icons-png.flaticon.com/512/1389/1389234.png

To set width/height, use centerImageSizeRatio. This ratio should be a float between 0 and 1. It determines how much space the center image takes up.

https://quickchart.io/qr?text=Here's my text&centerImageUrl=https://cdn-icons-png.flaticon.com/512/1389/1389234.png&centerImageSizeRatio=0.75

Alternatively, you can specify width and height in pixels using centerImageWidth and centerImageHeight.

Note that the image URLs used in QR codes must be accessible on the public internet. Base64 data URIs are also supported.

caution

You should always test the QR code after overlaying an image. This is because an image can potentially block critical portions of the QR code. You can guard against this by making sure the image covers less than ~30% of the available area.

tip

Remember to URL-encode the centerImageUrl parameter. Otherwise the URL will not work correctly if it contains special characters (the QR builder takes care of this automatically).

Text below QR code

You can add a caption below your QR code by using the caption, captionFontFamily, and captionFontSize parameters. This allows for further customization and can be particularly useful for branding or providing additional context.

For example:

https://quickchart.io/qr?text=abc123&caption=TextBelowQr&captionFontFamily=mono&captionFontSize=20

Bulk QR code generator

The API can generate bulk QR codes, but if you're looking to generate codes quickly, try our web-based bulk QR code generator.

Migrating from Google Image Charts

Google Image Chart parameters such as cht, chs, and chl are supported by the API.

This means that to migrate, you only need to replace chart.googleapis.com with quickchart.io:

https://quickchart.io/chart?cht=qr&chs=150x150&chl=Testing123

Troubleshooting

Parameters or Special Characters not working

When creating QR codes with QuickChart, you may find that certain parameters, special characters, or parts of the URL are not correctly preserved when the QR code is scanned.

Root Cause

This issue typically occurs when the URL or text content in the QR code is not properly URL-encoded within the QuickChart API call.

Solution: URL Encode the text or chl Parameter

To resolve this issue, you need to URL encode the entire content that you're putting into the QR code. This applies to both the text parameter in the new API and the chl parameter if you're using the Google Image Charts compatible API.

Steps to URL Encode:
  1. Use a URL Encoding Tool:

    • Use an online URL encoder or a function in your programming language
    • Encode the full content of your QR code, including any special characters or parameters
  2. Update Your QuickChart API Call:

    • Replace the unencoded content in your text or chl parameter with the encoded version
Example:

Original content:

https://example.com/page?param1=value1&param2=value2

Encoded content (to be used in the 'text' or 'chl' parameter):

https%3A%2F%2Fexample.com%2Fpage%3Fparam1%3Dvalue1%26param2%3Dvalue2

Complete QuickChart API call with encoded content:

https://quickchart.io/qr?text=https%3A%2F%2Fexample.com%2Fpage%3Fparam1%3Dvalue1%26param2%3Dvalue2