{
 "kind": "tool",
 "slug": "qrcode-npm",
 "path": "tools/qrcode-npm/",
 "name": "qrcode (JavaScript)",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Files, images and media",
   "tools/files-media/"
  ]
 ],
 "lead": "Generate QR codes on server and client using canvas with Node.js and browser support.",
 "chips": [
  {
   "label": "Files, images and media",
   "path": "tools/files-media/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install qrcode"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/soldair/node-qrcode"
  },
  {
   "label": "Website",
   "href": "http://github.com/soldair/node-qrcode"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from npm.",
   "src": "https://github.com/soldair/node-qrcode"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Quiet for a year",
   "status": "cond",
   "sub": "Last change Aug 23, 2024",
   "note": "",
   "src": "https://github.com/soldair/node-qrcode"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "124 projects",
   "status": "info",
   "sub": "#6 of 281 in its category",
   "note": "Dependency in 124 public GitHub projects set up for AI coding agents that we scanned (2.0%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What qrcode (JavaScript) does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "qrcode (JavaScript) popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "74",
       "of": "/ 100",
       "l": "Gid Score, #218 overall"
      },
      {
       "n": "42.6M",
       "l": "downloads a week, npm"
      },
      {
       "n": "8,193",
       "l": "GitHub stars"
      },
      {
       "n": "124",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How qrcode (JavaScript) is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "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%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "90 projects, 2.7%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "61 projects, 2.0%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "48 projects, 2.0%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "15 projects, 3.2%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "10 projects, 2.9%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      },
      {
       "l": "10 projects, 3.6%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      },
      {
       "l": "9 projects, 2.7%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "7 projects, 1.5%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 71.8% of its projects",
       "v": "Zod",
       "path": "tools/zod/"
      },
      {
       "l": "In 74.2% of its projects",
       "v": "React",
       "path": "tools/react/"
      },
      {
       "l": "In 50.8% of its projects",
       "v": "tsx",
       "path": "tools/tsx/"
      },
      {
       "l": "In 58.9% of its projects",
       "v": "Vitest",
       "path": "tools/vitest/"
      },
      {
       "l": "In 56.5% of its projects",
       "v": "Lucide React",
       "path": "tools/lucide-react/"
      },
      {
       "l": "In 92.7% of its projects",
       "v": "TypeScript",
       "path": "tools/typescript/"
      },
      {
       "l": "In 54.0% of its projects",
       "v": "Tailwind Merge",
       "path": "tools/tailwind-merge/"
      },
      {
       "l": "In 53.2% of its projects",
       "v": "clsx",
       "path": "tools/clsx/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "qrcode (JavaScript) in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Automatic mixed-mode segmentation",
       "v": "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\"."
      },
      {
       "l": "Browser bundle with old-browser support",
       "v": "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."
      },
      {
       "l": "A CLI that prints to the terminal",
       "v": "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."
      },
      {
       "l": "PNG, JPEG or WebP data URIs",
       "v": "<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."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Binary data must not go through a string",
       "v": "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."
      },
      {
       "l": "@types/qrcode rejects binary segments",
       "v": "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."
      },
      {
       "l": "Kanji compression needs an extra helper",
       "v": "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."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Generate a data URL with promises or async/await"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Javascript",
       "code": "import QRCode from 'qrcode'\n\n// With promises\nQRCode.toDataURL('I am a pony!')\n  .then(url => {\n    console.log(url)\n  })\n  .catch(err => {\n    console.error(err)\n  })\n\n// With async/await\nconst generateQR = async text => {\n  try {\n    console.log(await QRCode.toDataURL(text))\n  } catch (err) {\n    console.error(err)\n  }\n}"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about qrcode (JavaScript)",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Packages around it",
       "items": [
        "zod: Schema validation",
        "lucide-react: React icon set",
        "vitest: Test runner",
        "tailwind-merge: Tailwind class merging",
        "react: UI library",
        "clsx: className builder"
       ]
      },
      {
       "title": "More in Files, images and media",
       "path": "tools/files-media/",
       "items": [
        {
         "text": "Sharp",
         "path": "tools/sharp/"
        },
        {
         "text": "Pillow",
         "path": "tools/pillow/"
        },
        {
         "text": "Nodemailer",
         "path": "tools/nodemailer/"
        },
        {
         "text": "jsPDF",
         "path": "tools/jspdf/"
        },
        {
         "text": "SheetJS",
         "path": "tools/xlsx/"
        },
        {
         "text": "JSZip",
         "path": "tools/jszip/"
        },
        {
         "text": "PDF.js",
         "path": "tools/pdfjs-dist/"
        },
        {
         "text": "openpyxl",
         "path": "tools/openpyxl/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "qrcode (JavaScript)",
       "me": true,
       "facts": [
        "MIT",
        "Gid 74",
        "42.6M/wk"
       ]
      }
     ],
     "more": "Compare qrcode (JavaScript) with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "npm install qrcode"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## qrcode\n- Leave encoding to auto mode and omit `version`. The README says the version option is not needed unless a specific version is required.\n- Pass binary payloads as `[{ data: <Uint8ClampedArray or Buffer>, mode: 'byte' }]`, never as a string. Values are clamped to 0-255.\n- With `@types/qrcode`, put `// @ts-ignore` above a binary data segment, because the types expect `data: string`.\n- 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.\n- Use `toFile` and `toFileStream` only on the server. In the browser use `toCanvas`, `toDataURL`, `toString` or `create`.\n- For Kanji-mode compression, pass `toSJISFunc` from `qrcode/helper/to-sjis`. Otherwise encode kanji in Byte mode.\n- Promises and async/await can replace the callback. Handle errors with `.catch` or `try`/`await`.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm qrcode"
  ],
  [
   "Category",
   "Files, images and media"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Latest version",
   "1.5.4, August 5, 2024"
  ],
  [
   "On GitHub since",
   "December 2010"
  ],
  [
   "Gid Score",
   "74.5"
  ],
  [
   "Rank in category",
   "#6 of 281"
  ],
  [
   "GitHub",
   "soldair/node-qrcode"
  ],
  [
   "Last change",
   "Aug 23, 2024"
  ]
 ],
 "good": [
  "Used by react-native-qrcode-svg, as listed by the source; we have not checked each one."
 ],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/soldair.png"
}