If you use Google Sheets to manage event registrations, inventory tracking, or business cards, you might find yourself manually using third-party websites to generate QR codes for URLs or ID numbers and then painstakingly pasting the images back into your spreadsheet.
This manual process is entirely unnecessary. By combining Google Sheets’ native IMAGE function with a free, public API (like the Google Chart API), you can create a dynamic formula that automatically generates and displays a unique QR code directly inside any cell based on your data.
The Formula Structure
The IMAGE function allows Google Sheets to pull a picture from any URL on the internet and display it inside a cell. By pointing this function at a QR code generation API, and feeding it the data from an adjacent cell, the image generated is a perfect, scannable QR code.
Here is the core formula we will use:
=IMAGE("https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=" & ENCODEURL(A2))
How to Implement It
Imagine you have a list of website URLs in Column A (starting at cell A2), and you want to generate a corresponding QR code for each URL in Column B.
- Click on cell B2.
- Paste the formula provided above into the formula bar.
- Press Enter.
A QR code will immediately render inside cell B2. You can then use the fill handle (the small blue square in the bottom right corner of the cell) to drag the formula down the entire column, instantly generating unique QR codes for every single URL in your list.
Understanding the Formula Components
If you want to customize the QR codes, it is helpful to understand exactly what the API URL is doing:
chs=150x150: This defines the size of the generated image in pixels. If you need a larger, higher-resolution QR code for printing, simply change this to300x300or500x500.cht=qr: This tells the Google Chart API that the specific chart type you want to generate is a QR code.chl=: This is the data parameter. Everything after this equals sign is what gets encoded into the black and white squares.& ENCODEURL(A2): This is the most critical part. The ampersand joins the API URL to your cell data. TheENCODEURLfunction wraps your data to ensure any spaces, special characters, or complex URLs are properly formatted for web transmission before being turned into a QR code. Without this, complex URLs might generate broken or un-scannable codes.
Formatting Tips for Scannability
Because the generated image is locked inside the cell, it will automatically shrink to fit the row height. A tiny QR code is difficult for smartphone cameras to read.
To fix this, highlight all the rows containing your QR codes, right-click the row numbers on the left-hand side, select Resize rows, and set the height to at least 100 pixels. The QR codes will expand, making them crisp and easily scannable directly off your monitor.