Save time managing and deploying your node.js app

Nodejitsu has joined GoDaddy

We are excited to join GoDaddy to help spearhead their largest Node.js product: Website Builder. Please read our blog post to learn more about customer transition plans and our continued support for Open Source within the node community.

Want to know all the details?
Read the full blog post or read the GoDaddy Announcement.

npmawesome: Generating QR codes with Node.js

About the author

nodejitsu nodejitsu

Other popular posts

- Scaling Isomorphic Javascript Code - Keep a node.js server up with Forever - Package.json dependencies done right
- npm cheat sheet - 6 Must Have Node.js Modules

This is a guest post from Alex Gorbatchev and Nodejitsu loved what Alex was doing at and is now supporting the project. Like what you see here? Why don't you contribute on Github?

QR code is this super cool thing you probably have been seeing all over the place lately. It started appearing in North America a few years ago but the actual standard is close to two decades old. It allows you to embed any small amount of data that could be decoded with a basic camera equipped phone. Most common use case here is embedding URLs in printed adverising so that those who are interested could simply point their phone at the add and go to the site instead of having to type in URLs.

qr-image (Github: alexeyten/qr-image, License: MIT) is a module by Alexey Ten to render QR code with node.js and no external dependencies.

npm install qr-image


  • No dependecies. This is a really cool bit, if you look at package.json there are literally no dependencies there.
  • Generate image in png, svg, eps and pdf formats.
  • Support UTF-8.


var qr = require('qr-image');  
var fs = require('fs');

var code = qr.image('', { type: 'svg' });  
var output = fs.createWriteStream('nodejitsu.svg')


Because we are dealing with streams here, hooking this up to HTTP server is super easy.

var qr = require('qr-image');  
var express = require('express');

var app = express();

app.get('/', function(req, res) {  
  var code = qr.image(new Date().toString(), { type: 'svg' });


Now, going to http://localhost:3000 will spit out a QR code with current time. Wicked!


QR code allows you embed pretty much any text, but with some additional formatting you can tell scanning applications about the data and what you want them to do with it. Here are a few most common formats:

Data Type Data Format
Website URL (include the “http://” so it recognizes the data as a website URL)
Pre-populated email address (include “mailto” so it recognizes the data as an email address)
Pre-Populated Telephone Number +16365553344 (URI should include the country code to support users outside the country of origin)
Contact Information LastName,FirstName;ADR:(insert address), (second address line), City, ST (Insert 5-digit zip code);TEL:+16365553344;;;DO NOT use parenthesis or line breaks in code.

*For QR Codes, the MECARD standard format shown above is more standard than vCard standard format

Pre-populated SMS Message smsto:number:message
Pre-populated MMS Message mms:number:subject
Map or Location Coordinates latitude, longitude, altitude in meters (a minus sign denotes a South latitude and a West longitude)code for Google offices: 40.71872,-73.98905, 100
Android Market URI for Android Devices For a QR code you must replace all punctuation with code. For example,market://search?q=pub:”Search Query” becomes:


YouTube Video youtube://ID (may work on iPhone, untested, unreleased, not standardized)
iCal Appointment BEGIN:VEVENT
SUMMARY:Test Meeting
(untested, unreleased, not standardized)