# qrcode (JavaScript) — card for AI agents

Generate QR codes on server and client using canvas with Node.js and browser support.

Category: Files, images and media · npm package `qrcode` · latest version 1.5.4 (checked 2026-11-01)
Install: `npm install qrcode`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## qrcode
- Leave encoding to auto mode and omit `version`. The README says the version option is not needed unless a specific version is required.
- Pass binary payloads as `[{ data: , mode: 'byte' }]`, never as a string. Values are clamped to 0-255.
- With `@types/qrcode`, put `// @ts-ignore` above a binary data segment, because the types expect `data: string`.
- Set `errorCorrectionLevel` deliberately. The default is `M`. The README says a low level such as `L` or `M` is safe for codes shown on a monitor. Higher levels reduce capacity.
- Use `toFile` and `toFileStream` only on the server. In the browser use `toCanvas`, `toDataURL`, `toString` or `create`.
- For Kanji-mode compression, pass `toSJISFunc` from `qrcode/helper/to-sjis`. Otherwise encode kanji in Byte mode.
- Promises and async/await can replace the callback. Handle errors with `.catch` or `try`/`await`.

## What it is
- qrcode, the npm package from the node-qrcode repository, is a "QR code/2d barcode generator" for JavaScript. The README says it works on server and client, ships a CLI, and can save QR codes as images.
- You pass a string, or a list of segments, to functions such as `toCanvas`, `toDataURL` and `toString`. On the server you also get `toFile` and `toFileStream`. By default the library picks encoding modes itself and splits the text so the result is as small as possible. Options cover error correction level, symbol version (1 to 40), mask pattern, colors, margin and output type.
- It suits developers who need QR images in a web page, a Node service or a shell script. Much of the README covers QR internals: capacity tables, encoding modes, Kanji, binary data and multibyte characters. That material matters if your payloads are large or unusual.

## Caveats
- Binary data must not go through a string: Converting bytes to a JavaScript string first breaks the encoding. Pass a `Uint8ClampedArray`, a compatible array or a Node Buffer in a `byte` segment instead. The README also warns that element values are clamped to 0-255.
- @types/qrcode rejects binary segments: The `@types/qrcode` typings expect `data: string`. Passing binary data from TypeScript therefore needs a `// @ts-ignore` above the data segment.
- Kanji compression needs an extra helper: The Shift JIS conversion table is left out of the default bundle. To use Kanji mode, pass `toSJISFunc`, either from `qrcode/helper/to-sjis` or from the separate `qrcode.tosjis.min.js` file. Without it, kanji can still be encoded in Byte mode.
- ECI is incomplete: UTF-8 text is encoded in Byte mode, and Extended Channel Interpretation is not fully implemented. The README says most readers still recognise multibyte characters. It also notes that one kanji, kana or emoji can take up to 4 bytes.
- Error correction costs capacity: There are four levels, from L (~7%) to H (~30%) of damaged surface tolerated. The default is `M`. In Byte mode, level H holds 1273 characters against 2953 at level L.

## Numbers (AgentGid data)
- Gid Score: 74.5 (#218 of all tools, 13 of 281 in its category)
- Used in 124 public projects set up for AI coding agents (2.0%)
- Downloads last week: 42,611,418 (as of 2026-11-24), +42.8% over 4 weeks
- GitHub stars: 8,193 (as of 2026-11-24)
- Last push: 2024-08-23

## Often used with
Zod 71.8%, React 74.2%, tsx 50.8%, Vitest 58.9%, Lucide React 56.5%, TypeScript 92.7%

## Links
- AgentGid page: https://agentgid.com/tools/qrcode-npm/
- Homepage: http://github.com/soldair/node-qrcode
- Repository: https://github.com/soldair/node-qrcode
- Source: https://github.com/soldair/node-qrcode#readme
- Source: https://github.com/soldair/node-qrcode
- Source: https://www.npmjs.com/package/qrcode

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
