Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

qrcode (JavaScript)

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

Files, images and mediaNPM

GitHubWebsite

1. License

License from npm.

github.com/soldair/node-qrcode

From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error

What qrcode (JavaScript) does

qrcode splits your input into mixed-mode segments by default to get the shortest bitstream. The same package draws QR codes to a canvas in the browser, writes PNG or SVG files on a server, and prints them in a terminal from its CLI.

qrcode (JavaScript) popularity

74 / 100
Gid Score, #218 overall
42.6M
downloads a week, npm
8,193
GitHub stars
124
agent projects use it
qrcode (JavaScript): downloads per weeknpm, qrcode 42,611,418
qrcode (JavaScript): GitHub starssoldair/node-qrcode 8,193

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How qrcode (JavaScript) is used

  • qrcode (JavaScript) is a dependency in 124 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (2.5% of the 4,867 JavaScript/TypeScript ones), #6 of 281 in files, images and media.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 397; those are left out of every share on this page.
  • Projects that use it most often also use Zod (71.8%), React (74.2%), tsx (50.8%).

By coding agent

90 projects, 2.7%
61 projects, 2.0%
48 projects, 2.0%
15 projects, 3.2%
10 projects, 2.9%
10 projects, 3.6%
9 projects, 2.7%
7 projects, 1.5%

Often used with

In 71.8% of its projects
In 74.2% of its projects
In 50.8% of its projects
In 58.9% of its projects
In 56.5% of its projects
In 92.7% of its projects
In 54.0% of its projects
In 53.2% of its projects

qrcode (JavaScript) in practice

Strengths

Automatic mixed-mode segmentation

By default the input string is split into segments, each in the mode that keeps the bitstream shortest. The library supports Numeric, Alphanumeric, Kanji and Byte modes. The README's example <code>ABCDE12345678?A1A</code> becomes Alphanumeric, Numeric and Byte segments. The README calls auto mode "the preferred way to generate the QR Code".

Browser bundle with old-browser support

You can load it through Browserify or Webpack, or as a precompiled script from the <code>build/</code> folder. The README says that bundle supports Internet Explorer 10+, Safari 5.1+ and all evergreen browsers.

A CLI that prints to the terminal

If you install it globally, <code>qrcode "some text"</code> draws the code in the terminal. Adding <code>-o out.png</code> saves a file. The output type is guessed from the <code>png</code>, <code>svg</code> or <code>txt</code> extension.

PNG, JPEG or WebP data URIs

<code>toDataURL</code> defaults to <code>image/png</code> and can also return <code>image/jpeg</code> or <code>image/webp</code>. For the two lossy formats, a quality setting between 0 and 1 is available, with a default of 0.92.

Watch out for

Binary data must not go through a string

Converting bytes to a JavaScript string first breaks the encoding. Pass a <code>Uint8ClampedArray</code>, a compatible array or a Node Buffer in a <code>byte</code> segment instead. The README also warns that element values are clamped to 0-255.

@types/qrcode rejects binary segments

The <code>@types/qrcode</code> typings expect <code>data: string</code>. Passing binary data from TypeScript therefore needs a <code>// @ts-ignore</code> 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 <code>toSJISFunc</code>, either from <code>qrcode/helper/to-sjis</code> or from the separate <code>qrcode.tosjis.min.js</code> file. Without it, kanji can still be encoded in Byte mode.

Generate a data URL with promises or async/await

import QRCode from 'qrcode'

// With promises
QRCode.toDataURL('I am a pony!')
  .then(url => {
    console.log(url)
  })
  .catch(err => {
    console.error(err)
  })

// With async/await
const generateQR = async text => {
  try {
    console.log(await QRCode.toDataURL(text))
  } catch (err) {
    console.error(err)
  }
}

More about qrcode (JavaScript)

Packages around it
  • zod: Schema validation
  • lucide-react: React icon set
  • vitest: Test runner
  • tailwind-merge: Tailwind class merging
  • react: UI library
  • clsx: className builder
More in Files, images and media

Alternatives

qrcode (JavaScript) This page

MITGid 7442.6M/wk

Compare qrcode (JavaScript) with another tool

Get started

Install it.

npm install qrcode

Rules for your agent

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: <Uint8ClampedArray or Buffer>, 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`.