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 Name | Description | Required? | Default value |
---|---|---|---|
text | Content of the QR code (can be a URL or any other string) | Yes | |
format | Format of QR code, either png, svg, or base64 | png | |
margin | Whitespace around QR image | 4 | |
size | Width and height dimension of the image | 150 | |
dark | Hex color code of "dark" QR grid cells | 000000 (black) | |
light | Hex color code of "light" QR grid cells | ffffff (white) | |
ecLevel | Error correction level (L, M, Q, H) | M (H if center image is present) | |
centerImageUrl | URL of image to show in the center. Must be URL-encoded. | ||
centerImageSizeRatio | How much space to take up, between 0.0 and 1.0 | 0.3 | |
centerImageWidth | Width of center image in pixels | ||
centerImageHeight | Height of center image in pixels | ||
caption | Caption text to display below the QR code. | ||
captionFontFamily | Font family of the caption text | 'sans-serif' | |
captionFontSize | Font size of the caption text in pixels. | 10 | |
captionFontColor | Color caption text, color names or hex code. | black |
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¢erImageUrl=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¢erImageUrl=https://cdn-icons-png.flaticon.com/512/1389/1389234.png¢erImageSizeRatio=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.
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.
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:
-
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
-
Update Your QuickChart API Call:
- Replace the unencoded content in your
text
orchl
parameter with the encoded version
- Replace the unencoded content in your
Example:
Original content:
https://example.com/page?param1=value1¶m2=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