Awesome Open Source
Awesome Open Source

Ruby Style Guide


rqrcode_core is a library for encoding QR Codes in pure Ruby. It has a simple interface with all the standard qrcode options. It was originally adapted in 2008 from a Javascript library by Kazuhiko Arase.


  • rqrcode_core is a Ruby only library. It requires no 3rd party libraries. Just Ruby!
  • It is an encoding library. You can't decode QR Codes with it.
  • The interface is simple and assumes you just want to encode a string into a QR Code, but also allows for encoding multiple segments.
  • QR Code is trademarked by Denso Wave inc.

rqrcode_core is the basis of the popular rqrcode gem []. This gem allows you to generate different renderings of your QR Code, including png, svg and ansi.


Add this line to your application's Gemfile:

gem "rqrcode_core"

And then execute:

$ bundle

Or install it yourself as:

$ gem install rqrcode_core

Basic Usage

$ require "rqrcode_core"
$ qr ="")
$ puts qr.to_s


xxxxxxx x  x x   x x  xx  xxxxxxx
x     x  xxx  xxxxxx xxx  x     x
x xxx x  xxxxx x       xx x xxx x
... etc

Multiple Encoding Support

$ require "rqrcode_core"
$ qr =[{data: "byteencoded", mode: :byte_8bit}, {data: "A1" * 100, mode: :alphanumeric}, {data: "1" * 500, mode: :number}])

This will create a QR Code with byte encoded, alphanumeric and number segments. Any combination of encodings/segments will work provided it fits within size limits.

Doing your own rendering

require "rqrcode_core"

qr ="")
qr.modules.each do |row|
  row.each do |col|
    print col ? "#" : " "

  print "\n"


The library expects a string or array (for multiple encodings) to be parsed in, other args are optional.

data - the string or array you wish to encode

size - the size (integer) of the QR Code (defaults to smallest size needed to encode the string)

max_size - the max_size (Integer) of the QR Code (default RQRCodeCore::QRUtil.max_size)

level  - the error correction level, can be:
  * Level :l 7%  of code can be restored
  * Level :m 15% of code can be restored
  * Level :q 25% of code can be restored
  * Level :h 30% of code can be restored (default :h)

mode - the mode of the QR Code (defaults to alphanumeric or byte_8bit, depending on the input data, only used when data is a string):
  * :number
  * :alphanumeric
  * :byte_8bit
  * :kanji

Example"", size: 1, level: :m, mode: :alphanumeric)



You can run the test suite using:

$ ./bin/setup
$ rake

or try the project from the console with:

$ ./bin/console


The project uses standardrb and can be run with:

$ ./bin/setup
$ rake standard # check
$ rake standard:fix # fix


On 64 bit systems when generating lots of QR Codes the lib will consume more memory than on a 32 bit systems during the internal "right shift zero fill" steps (this is expected). In tests though, it's shown that by forcing the lib to think you're on a 32 systems greatly reduces the memory footprint. This could of course have undesired consequences too! but if you're happy to try, you can use the RQRCODE_CORE_ARCH_BITS ENV to make this change. e.g RQRCODE_CORE_ARCH_BITS=32.


Bug reports and pull requests are welcome on GitHub at


The gem is available as open source under the terms of the MIT License.

Alternatives To Rqrcode_core
Select To Compare

Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Ruby (223,317
Encoding (6,535
Qrcode (5,802
Qr Code (5,788