explaingit

davidshimjs/qrcodejs

14,278JavaScriptAudience · developerComplexity · 1/5LicenseSetup · easy

TLDR

A tiny, dependency-free JavaScript library that generates QR code images directly in the browser using Canvas or HTML tables, no server required, just include the script and point it at a div.

Mindmap

mindmap
  root((repo))
    What it does
      QR code generation
      Browser only
      No server needed
    Rendering
      HTML5 Canvas
      HTML table fallback
    Options
      Size control
      Custom colors
      Error correction
    Compatibility
      IE 6 through 10
      Chrome Firefox Safari
      Mobile browsers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add a shareable QR code to any webpage that encodes a URL or text for visitors to scan with a phone.

USE CASE 2

Generate QR codes dynamically in a web app without any server-side processing or external API calls.

USE CASE 3

Embed a QR code in a checkout or payment page that encodes a payment link or confirmation code.

Tech stack

JavaScript

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

QRCode.js is a small JavaScript library for generating QR codes directly in a web browser. A QR code is the square barcode pattern you can scan with a phone camera to open a link or read a piece of text. This library creates those images on the fly, inside any webpage, without needing a server to generate them. It works by drawing the QR code using the HTML5 Canvas element if the browser supports it, or by falling back to an HTML table for older browsers. The library has no dependencies, meaning you do not need to install or load anything else alongside it. Usage is straightforward: you add a div to your page, include the script, and pass the div and the text you want encoded. Optional settings let you control the image size, the dark and light colors used in the pattern, and the error correction level, which determines how much of the QR code can be damaged or obscured while still remaining scannable. The library also provides two methods: one to clear the current code and one to generate a new code with different content. Browser support covers Internet Explorer 6 through 10, Chrome, Firefox, Safari, Opera, Mobile Safari, Android browsers, and Windows Mobile. The project is released under the MIT license.

Copy-paste prompts

Prompt 1
Show me how to add a QR code to my webpage using QRCode.js that updates live as a user types a URL into a text input.
Prompt 2
How do I customize the QR code colors and size in QRCode.js to match my brand, and increase error correction so it remains scannable when partially covered?
Prompt 3
I'm building a checkout page and want a QR code for a payment link using QRCode.js, show me the minimal HTML and JS needed.
Prompt 4
How do I use the QRCode.js clear method to reset the canvas and then regenerate a code with new text on button click?
Open on GitHub → Explain another repo

← davidshimjs on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.