Developers & agents
Generate a QR code in Google Apps Script
UrlFetchApp.fetch the keyless API and you have a QR blob: save it to Drive with DriveApp.createFile, place it in a Sheet with insertImage, or write =IMAGE() formulas into a column so every row gets its own code. No key, no OAuth scopes beyond fetch and the destination service.
First: do you even need a script?
If the goal is "a QR code next to each URL in my sheet", the no-code =IMAGE() formula
does it without Apps Script at all. That route is written up in
how to make a QR code in Google Sheets.
Reach for a script when you need files in Drive, codes in Docs or Slides, batch output, or
regeneration on a trigger.
Fetch a code, save it to Drive
The keyless API needs no key, so
UrlFetchApp is the whole integration:
function saveQrToDrive() {
const url = "https://useqr.app/api/v1/qr?data="
+ encodeURIComponent("https://example.com") + "&size=1024";
const blob = UrlFetchApp.fetch(url).getBlob().setName("qr.png");
DriveApp.createFile(blob);
}
encodeURIComponent is mandatory, an unencoded & in the payload truncates the code's
contents silently. Add format=svg for vector output destined for
print.
A code per row in a Sheet
Writing =IMAGE() formulas from script scales cleanly, because Sheets then fetches and
displays each image itself:
function qrColumn() {
const sheet = SpreadsheetApp.getActiveSheet();
const urls = sheet.getRange("A2:A101").getValues().flat().filter(String);
urls.forEach((u, i) => {
sheet.getRange(i + 2, 2).setFormula(
'=IMAGE("https://useqr.app/api/v1/qr?data=' + encodeURIComponent(u) + '&size=512")'
);
});
}
For an image anchored over the grid rather than in a cell, sheet.insertImage(blob, 3, 2)
places a fetched blob at column 3, row 2. Spreadsheet-driven batch workflows more broadly
(including CSV export routes) are covered in
QR codes from a spreadsheet.
Quotas, and why formulas beat fetch loops
UrlFetchApp is quota-limited (20,000 calls per day on consumer accounts), and a fetch
loop over a big sheet burns it. The formula approach spends zero fetch quota (the
requests come from Sheets, not your script), and the API's immutable caching means each
distinct payload is only ever fetched once anyway.
Regenerate on a trigger
Because static codes never expire, regeneration is only needed when the source data changes. An installable trigger keeps a column honest:
function onEditInstallable(e) {
if (e.range.getColumn() !== 1) return; // only react to URL edits in column A
const row = e.range.getRow();
const value = e.range.getValue();
if (!value) return;
e.source.getActiveSheet().getRange(row, 2).setFormula(
'=IMAGE("https://useqr.app/api/v1/qr?data=' + encodeURIComponent(value) + '")'
);
}
Install it via Triggers → Add Trigger → On edit. Time-driven triggers suit nightly batch jobs that pull rows and write PNGs to a Drive folder. If your automation lives outside Google's stack, the same API drops into n8n, Zapier and Make with an HTTP node.
FAQ
How do I generate a QR code in Google Apps Script?
UrlFetchApp.fetch the keyless API URL with your data encoded, call getBlob(), and hand the blob to DriveApp, Sheets, Docs or Slides.
How do I put a QR code in every row of a Google Sheet?
Loop the rows and setFormula an =IMAGE() call per row, or skip scripting entirely and drag the formula down, no quota is consumed either way.
Does UrlFetchApp have a limit?
Yes: daily quotas apply (20,000 fetches on consumer accounts). Prefer =IMAGE() formulas for bulk sheets so Sheets does the fetching instead of your script.
Can the QR codes update automatically when data changes?
Yes. An installable on-edit trigger can rewrite the formula for the edited row, and time-driven triggers handle scheduled batch regeneration.
Try it: free, no signup
Related
- A free QR code API with no key, UseQR's REST API needs no signup, no API key and no SDK. GET /api/v1/qr?data=hello returns a PNG. The shortest form is /q/hello.png, which drops straight…
- How to make a QR code in Google Sheets, One formula: =IMAGE("https://useqr.app/api/v1/qr?data="&ENCODEURL(A2)): puts a live QR code in a cell. Fill it down and every row gets its own code.
- How to make QR codes from a spreadsheet, Upload the spreadsheet to the bulk tool (.xlsx works directly, no CSV export needed) map columns with merge fields, and download a ZIP of verified codes.
- QR codes in n8n, Zapier and Make, Generate QR codes in automation workflows with one HTTP request node against a keyless API, no connector, no credential setup, no per-call cost. Recipes included.