Skip to content
GWT QR Code Generation
Java Ruby
Branch: master
Clone or download
Pull request Compare This branch is 178 commits ahead, 295 commits behind nayuki:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



Build Status

The library is a GWT port of QR-Code-generator that enables the generation of QR Codes. This original project aims "... to be the best, clearest QR Code generator library ... The primary goals are flexible options and absolute correctness". The best place to read about the original project is the project's website.

Core features:

  • Significantly shorter code but more documentation comments compared to competing libraries
  • Supports encoding all 40 versions (sizes) and all 4 error correction levels, as per the QR Code Model 2 standard
  • Output formats: Raw modules/pixels of the QR symbol, SVG XML string, HTML5 canvas
  • Encodes numeric and special-alphanumeric text in less space than general text

Manual parameters:

  • User can specify minimum and maximum version numbers allowed, then library will automatically choose smallest version in the range that fits the data
  • User can specify mask pattern manually, otherwise library will automatically evaluate all 8 masks and select the optimal one
  • User can specify absolute error correction level, or allow the library to boost it if it doesn't increase the version number
  • User can create a list of data segments manually and add ECI segments

Quick Start

The simplest way to use the library is to add the dependency into the build system. i.e.


Then add the snippet <inherits name='org.realityforge.gwt.qr_code.QrCode'/> into the .gwt.xml module file. Then you can generate the svg via:

Render a url qr code as SVG:

// Generate a simple text base url QR Code with High error correction
final QrCode qrCode = QrCodeTool.encodeText( "", Ecc.HIGH );

// Render the qr code as a svg element
final Element div = DomGlobal.document.createElement( "div" );
div.setAttribute( "style", "width:200px" );
div.innerHTML = qrCode.toSvgString( 2 );
DomGlobal.document.body.appendChild( div );

Render a unicode qr code on canvas element:

// Generate a ‎🎉 QR Code with medium error correction
final QrCode qrCode = QrCodeTool.encodeText( "\u200E\uD83C\uDF89", Ecc.MEDIUM );

final HTMLCanvasElement canvas = (HTMLCanvasElement) DomGlobal.document.createElement( "canvas" );
final int border = 2;
// 8 pixels per "module"
final double scale = 8;
// Draw the canvas
qrCode.drawCanvas( scale, border, canvas );
DomGlobal.document.body.appendChild( canvas );

Manually render a numeric qr code:

// Generate a QrCode using manual process
final QrSegment segment = QrCodeTool.makeNumericSegment( "3141592653589793238462643383" );
final QrCode qrCode = QrCodeTool.encodeSegments( Collections.singletonList( segment ), Ecc.HIGH, 5, 5, 2, false );
for ( int y = 0; y < qrCode.getSize(); y++ )
  for ( int x = 0; x < qrCode.getSize(); x++ )
    final boolean isPixelBlack = qrCode.getModule( x, y );
    // paint x, y, isPixelBlack

More Information

For the source code and project support please visit the GitHub project.


The library was released as open source so others could benefit from the project. We are thankful for any contributions from the community. A Code of Conduct has been put in place and a Contributing document is under development.


GWT QR Code Generator is licensed under MIT License.


This library is a reworking of the magnificent QR-Code-generator by Nayuki Minase. The changes made the library GWT compatible and made it easier for the GWT compiler to optimize. Support was also removed for the Kanji optimization. Any bugs are likely caused by the current author while the credit for the code all goes to the original author.

You can’t perform that action at this time.