qrcodejs
Cross-browser QRCode generator for javascript
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.
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.
Where it fits
- Add a shareable QR code to any webpage that encodes a URL or text for visitors to scan with a phone.
- Generate QR codes dynamically in a web app without any server-side processing or external API calls.
- Embed a QR code in a checkout or payment page that encodes a payment link or confirmation code.