QR codes in JavaScript!

The QR Code (Quick Response) is alphanumeric, two-dimensional, square graphic code, invented by the Japanese company Denso Wave in 1994.

With these codes we meet more frequently. Today’s article is about how to work with QR codes in JavaScript. It’s quite simple with the right tools.

QR codes in JavaScript

There are many solutions for this purpose, so it’s good to try a proven solution in the form of JavaScript library / jQuery plug-in. Writing such a library on your own is quite ambiguous task, which takes more time and effort.

Let’s do a small review of the tools, which can really support our work with QR codes in JavaScript.


This is a JavaScript library to generate QR codes. It has no dependencies. Here is an example using the configuration options:

var qrcode = new QRCode("test", {
    text: "https://javascript-html5-tutorial.com/",
    width: 128,
    height: 128,
    colorDark : "#000000",
    colorLight : "#ffffff",
    correctLevel : QRCode.CorrectLevel.H






Another generator — a small jQuery plugin, available under the MIT license:


jquery('#qrcode').qrcode("Easy to use …");


Excellent project. Another jQuery plugin, that offers much more. It has a lot of configuration options. Programmer can customize many of the typical parameters for QR code, that will be generated.


    // render method: 'canvas', 'image' or 'div'
    render: 'canvas',

    // version range somewhere in 1 .. 40
    minVersion: 1,
    maxVersion: 40,

    // error correction level: 'L', 'M', 'Q' or 'H'
    ecLevel: 'L',

    // offset in pixel if drawn onto existing canvas
    left: 0,
    top: 0,

    // size in pixel
    size: 200,

    // code color or image element
    fill: '#000',

    // background color or image element, null for transparent bg
    background: null,

    // content
    text: 'no text',

    // corner radius relative to module width: 0.0 .. 0.5
    radius: 0,

    // quiet zone in modules
    quiet: 0,

    // modes
    // 0: normal
    // 1: label strip
    // 2: label box
    // 3: image strip
    // 4: image box
    mode: 0,

    mSize: 0.1,
    mPosX: 0.5,
    mPosY: 0.5,

    label: 'no label',
    fontname: 'sans',
    fontcolor: '#000',

    image: null

Project homepage:


Reading QR code in JavaScript

OK, we talked about writing QR codes in JavaScript. What with reading? No problem! We also can deal with.

QR code API

We can generate and decode (read) QR codes using Web API: api.qrserver.com.




We can read QR code (assuming we have web camera) on-line, directly on the website:


There is also a simple extension — qrcode-reader, but this is for node.js:



OK! For our needs to work with QR codes in JavaScript, presented solutions were enough. We can enjoy working with QR codes even in JavaScript.


2 Responses to “QR codes in JavaScript!”

  1. DirectCode says:


  2. Make a mobile app for your product says:

    Make a mobile app for your product

    […]QR codes in JavaScript! — javascript-html5-tutorial.com[…]