Generating QR Codes (using Google Charts API)

03 Jan 2017   -   1 min read

EDIT: Charts API has been deprecated by Google

QR Code (abbreviated from Quick Response Code) is a machine-readable code consisting of an array of black and white squares, typically used for storing URLs or other information for reading by the camera on a smartphone.

As an example, here’s the QR Code containing link to the homepage of this site:

QR Code

The Google Chart API is a tool that lets people easily create a chart from some data and embed it in a web page. Google creates a PNG image of a chart from data and formatting parameters in an HTTP request.

Here’s the general format:

https://chart.googleapis.com/chart?cht=qr&chl=DATA&chs=160x160&chld=L|0

Parameters Description
chl The content to encode. Make sure the content is HTML encoded, e.g. %20 for space.
cht Chart type. qr for QR Code.
chs Dimensions of the generated QR Code image as <width>x<height>.

See Google Developer Site for more info.

So, here’s a CodePen sample:

See the Pen QR Code Generator by Mathew Sachin (@MathewSachin) on CodePen.


Share this: