# Generate a QR code with curl

> curl -o qr.png \"https://useqr.app/q/hello.png\" is the whole thing. No key, no auth header, no SDK. Add query parameters for size, format and styling, and use format=svg when you want vector output for print.

Source: https://useqr.app/docs/developers/generate-a-qr-code-with-curl · Last reviewed 2026-08-21 · UseQR is free forever, MIT licensed, no signup.

---

## The basics

```bash
# PNG, default 512px
curl -o qr.png "https://useqr.app/q/hello.png"

# SVG for print
curl -o qr.svg "https://useqr.app/q/hello.svg"

# Larger, and a brand colour
curl -o qr.png "https://useqr.app/api/v1/qr?data=https://example.com&size=1024&color=6366f1"
```

## URL-encode the payload

Anything containing `&`, `?`, `#`, `+` or a space must be encoded, or your shell and the
server will disagree about where the parameter ends. `curl --data-urlencode` with `-G` does
it for you:

```bash
curl -G -o qr.png "https://useqr.app/api/v1/qr" \
  --data-urlencode "data=https://example.com/sale?utm_source=poster&utm_medium=qr" \
  --data "size=1024"
```

## Typed payloads

```bash
# WiFi
curl -o wifi.png "https://useqr.app/api/v1/wifi?ssid=CafeGuest&password=espresso&security=WPA"

# vCard
curl -G -o card.svg "https://useqr.app/api/v1/vcard" \
  --data-urlencode "fn=Ada" --data-urlencode "ln=Lovelace" \
  --data-urlencode "email=ada@example.com" --data "format=svg"
```

## Get the matrix instead of an image

```bash
curl -s "https://useqr.app/api/v1/qr?data=hello&format=json" | jq '.version, .size'
```

Returns the version, error-correction level, module count and the full module matrix as
arrays of 0 and 1 — useful if you are rendering yourself.

## Decode an existing code

```bash
curl -X POST --data-binary @qr.png "https://useqr.app/api/v1/decode"
curl "https://useqr.app/api/v1/decode?url=https://example.com/some-qr.png"
```

## Check a design still scans

```bash
curl -s "https://useqr.app/api/v1/verify?data=hello&color=cccccc" | jq
```

The verify endpoint renders the code with your styling, rasterises it, decodes it back, and
tells you whether it survived — with a `fix` if it did not.

## Batch

```bash
curl -X POST "https://useqr.app/api/v1/qr/batch" \
  -H "Content-Type: application/json" \
  -d '{"items":[{"data":"one"},{"data":"two"}]}'
```

Up to 100 items per call.

## A shell function worth having

```bash
qr() { curl -sG -o "${2:-qr.png}" "https://useqr.app/api/v1/qr" --data-urlencode "data=$1" --data "size=1024"; }
# usage: qr "https://example.com" site.png
```

## FAQ

### How do I generate a QR code from the command line?
curl the keyless endpoint and write the response to a file: curl -o qr.png "https://useqr.app/q/hello.png". No authentication is required.

### How do I encode a URL with query parameters?
Use curl -G with --data-urlencode so the ampersands inside your payload are encoded rather than being parsed as separate parameters.

### Can I get SVG instead of PNG?
Yes — use the .svg path form, or add format=svg. SVG is the right choice for anything going to print.

### Can I check that a styled code still scans from the shell?
Yes. The verify endpoint renders, rasterises and decodes the code and returns whether it survived, along with a suggested fix if not.

## Try it

- https://useqr.app/developers
