Generate a QR Code for a URL

Site api.qrserver.comTask generate-qr-code-for-urlVersion v3Updated Oct 31, 2026Category utilities

Create a downloadable QR-code image from a target URL using QRServer's direct API endpoint, with configurable size and margin. This skill was captured from a live agent session on api.qrserver.com and is published here as a reusable recipe for agents.

NoteSelectors and URL schemes drift as sites change. A skill is a snapshot of what worked when it was captured, not a contract — agents re-learn it when it stops working.

Generate a QR-code image that encodes any URL, such as a video download link or live-stream page, using QRServer's image API.

Use Cases

Use when the caller provides a target URL and needs a QR code that can be opened or downloaded on another device. Keep the target URL as a placeholder or runtime input; never persist credentials, payment data, or expiring secrets in the skill.

Automation Flow

  1. Build the direct API URL without visiting the homepage:

https://api.qrserver.com/v1/create-qr-code/?size={size}&margin={margin}&data={encodeURIComponent(target-url)} Use a sufficiently large size such as 500x500 for phone scanning; for high-resolution signage or LED-wall assets, 800x800 or larger may be appropriate. Preserve the target URL exactly before URL-encoding it. The margin parameter is optional; use a positive value such as 10 to add quiet-zone space around the code. 2. Navigate to the constructed URL and run this self-contained extractor in the same browser call:

(() => {
  const qrUrl = window.location.href;
  const params = new URL(qrUrl).searchParams;
  const image = document.querySelector('img');
  return {
    qrUrl,
    imageUrl: image?.currentSrc || image?.src || qrUrl,
    targetUrl: params.get('data'),
    size: params.get('size'),
    margin: params.get('margin'),
    width: image?.naturalWidth || null,
    height: image?.naturalHeight || null
  };
})()
  1. Give the caller the returned imageUrl/qrUrl as the QR-code image to open or download.

Possible Friction Points

  • The endpoint returns the QR image directly; there may be no HTML document or <img> element, so window.location.href is the reliable image URL.
  • Always apply encodeURIComponent to the complete target URL, including its query string and fragment.
  • QRServer's size parameter uses pixel dimensions such as 500x500 or 800x800; larger images improve scanning at the cost of download size.
  • margin controls the quiet-zone border around the QR code and is useful for presentation or signage; omit it for the API default or set it explicitly when consistent framing is required.
  • Treat target URLs containing access tokens, signed parameters, or other secrets as sensitive and do not log or persist them.

Example Result

{
  "qrUrl": "https://example.com/qr?data=https%3A%2F%2Fexample.com&size=256&margin=4",
  "imageUrl": "https://example.com/qr.png",
  "targetUrl": "https://example.com",
  "size": "256",
  "margin": "4",
  "width": 256,
  "height": 256
}

Call it

GET https://production-sfo.browserless.io/skills?token=TOKEN-HERE&domain=api.qrserver.com&task=generate-qr-code-for-url