Skip to content
a simple QRCode generation api for java built on top ZXING
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
android Roboelectric upgraded to 3.0 version in order to not have reflection … Sep 12, 2019
core set next version Jul 18, 2019
javase set next version Jul 18, 2019
.gitignore added settings to gitignore Nov 1, 2015
.travis.yml update readme Jul 18, 2019
checkstyle.xml #32 Added checkstyle plugin to pom with default sun coding conventions. Sep 20, 2014
pom.xml github packages Oct 12, 2019

Build Status Release

QRGen: a simple QRCode generation api for java built on top ZXING



Get it:

QRGen consists of three modules: core, javase and android.

As of 2.1.0 QRGen is available from QRGen is no longer deployed to maven central (ref: #61). Older releases are available from Maven Central Repository.




    allprojects {
        repositories {
            // ...
            maven { url "" }
Nexus proxy setup for jitpack

See for solution.

(thanks to @LTheobald for the heads up)

Java Application

When developing a Java application you need to add javase module to your list of dependencies. The required core module will be added automatically by your build system:


    dependencies {
        compile 'com.github.kenglxn.QRGen:javase:2.6.0'



When you want to use QRGen inside your android application you need to add the android module to your list of dependencies. The required core module will be added automatically by your build system:


    dependencies {
        compile 'com.github.kenglxn.QRGen:android:2.6.0'



Or you can clone and build yourself:

    git clone git://
    cd QRGen/
    mvn clean install


// get QR file from text using defaults
File file = QRCode.from("Hello World").file();

// get QR stream from text using defaults
ByteArrayOutputStream stream = QRCode.from("Hello World").stream();

// override the image type to be JPG
QRCode.from("Hello World").to(ImageType.JPG).file();
QRCode.from("Hello World").to(ImageType.JPG).stream();

// override image size to be 250x250
QRCode.from("Hello World").withSize(250, 250).file();
QRCode.from("Hello World").withSize(250, 250).stream();

// override size and image type
QRCode.from("Hello World").to(ImageType.GIF).withSize(250, 250).file();
QRCode.from("Hello World").to(ImageType.GIF).withSize(250, 250).stream();

// override default colors (black on white)
// notice that the color format is "0x(alpha: 1 byte)(RGB: 3 bytes)"
// so in the example below it's red for foreground and yellowish for background, both 100% alpha (FF).
QRCode.from("Hello World").withColor(0xFFFF0000, 0xFFFFFFAA).file();

// supply own outputstream
QRCode.from("Hello World").to(ImageType.PNG).writeTo(outputStream);

// supply own file name
QRCode.from("Hello World").file("QRCode");

// supply charset hint to ZXING
QRCode.from("Hello World").withCharset("UTF-8");

// supply error correction level hint to ZXING
QRCode.from("Hello World").withErrorCorrection(ErrorCorrectionLevel.L);

// supply any hint to ZXING
QRCode.from("Hello World").withHint(EncodeHintType.CHARACTER_SET, "UTF-8");

// encode contact data as vcard using defaults
VCard johnDoe = new VCard("John Doe")
                    .setAddress("John Doe Street 1, 5678 Doestown")
                    .setCompany("John Doe Inc.")

// encode email data
EMail email = new EMail("");

// encode mms data
MMS mms = new MMS("Hello World");

// encode sms data
SMS sms = new SMS("Hello World");

// encode MeCard data
MeCard johnDoe = new MeCard("John Doe");
johnDoe.setAddress("John Doe Street 1, 5678 Doestown");

// if using special characters don't forget to supply the encoding
VCard johnSpecial = new VCard("Jöhn Dɵe")
                        .setAddress("ëåäöƞ Sträät 1, 1234 Döestüwn");

// QRGen currently supports the following schemas:
// - BizCard
// - Bookmark
// - Email
// - GeoInfo
// - Girocode
// - GooglePlay
// - ICal
// - KddiAu
// - MMS
// - MeCard
// - SMS
// - Telephone
// - Url
// - VCard
// - Wifi
// - YouTube

Java SE only

When using java you can create svg files via .svg() terminal operator:

File file = QRCode.from("").svg();
File file = QRCode.from("").withSize(250, 250).withColor(30, 90).svg();

It's also possible to write svg to an OutputStream with terminal operation:

OutputStream outs = // ...

Android only

On Android you have a special method bitmap() which returns a without creating a File object before, so you can use the generated immediately inside an ImageView:

Bitmap myBitmap = QRCode.from("").bitmap();
ImageView myImage = (ImageView) findViewById(;


You can’t perform that action at this time.