Generate QR codes in Deno, as base64-encoded images, completely dependency-free and requires no binary.
This is a port of zenozeng/node-yaqrcode, which itself is a port of the QR code generator in the d-project.
import { qrcode } from "https://deno.land/x/qrcode/mod.ts";
const base64Image = qrcode("bitcoin:ADDRESS?amount=0.5&label=ORDER"); // data:image/gif;base64,...
You can also add a custom size by specifying size
in the second parameter:
const fixedSizeImage = await qrcode("bitcoin:ADDRESS?amount=0.5&label=ORDER", { size: 500 });
CLI with DPX
After installing DPX, you can directly use the CLI using the dpx
command:
dpx qrcode <text>
Alternatively, you can use it directly from the CLI by using deno run
:
deno run https://deno.land/x/qrcode/cli.ts <text>
You can also install it globally using the following:
deno install https://deno.land/x/qrcode/cli.ts
Then, the package is available to run:
qrcode <text>
Run tests:
deno test
- To support typeNumber 40, use the
RS_BLOCK_TABLE
from davidshimjs/qrcodejs - To support UTF-8, use the code from davidshimjs/qrcodejs
- Returns a base64-encoded image URL
- zenozeng/node-yaqrcode is the Node.js project that is the origin of this implementation
- MIT ยฉ Denorg
- Original repo: MIT ยฉ Zeno Zeng
- "QR Code" is registered trademark of Denso Wave
A project by Denorg, the world's first Deno-focused community
organization and consulting company. Work with us โ