t |
Error Correction Level L (low) M (medium) Q (quartile) H (high)
Size 50 100 250 500 1000
Maximum Data per QR Code 100% 75% 50% 25% 10%
Entering emojis (for example 😀) will result in QR codes that are not scannable. Some unicode characters (for example ❤︎) work just fine.
To save the QR code, right-click on the image and "Save Image As".
Error Correction Level: A lower error correction level means more data can fit into a single QR code, but the QR code may be less reliable when scanning. A higher error correction level means less data can fit into a single QR code, but the codes may be more reliable.
Size: Smaller sizes may be harder to scan depending on the amount of data being displayed.
Maximum Data per QR Code: When entering a lot of data, there may be more data than can fit into a single QR code. At 100%, QR codes are made to display as much data as possible before we split the data across multiple QR codes. At 50%, QR codes are only made to display half as much data as they possibly can, which means more QR codes are needed to show the same amount of data, but the codes will be easier to scan.
Entered data SHA-256: This is the hash/fingerprint of the data entered into the text box.
Full QR code data SHA-256: This is the hash/fingerprint of the data shown in the QR code. When the all data fits into a single QR code, this will match the Entered data SHA-256.
QR Code generation performed with [qrcodejs](https://github.com/KeeeX/qrcodejs) released under the [MIT License](https://github.com/KeeeX/qrcodejs/blob/master/LICENSE).
SHA-256 code by Mozilla MDN Contributors licensed under CC-BY-SA 2.5.
View the source on GitHub
<script type="text/javascript"> document.getElementsByTagName('body')[0].style.textAlign = 'center'; document.getElementById('notes').style.textAlign = 'left'; document.getElementsByTagName('body')[0].style.padding = '1.0em'; $('div.wrap').first().css('max-width', 'inherit'); var qrcgen = {}; qrcgen.qrcode = new QRCode(document.getElementById("qrcode"), { width : 500, height : 500, correctLevel: 0, }); function sha256(str) { // We transform the string into an arraybuffer. var buffer = new TextEncoder("utf-8").encode(str); return crypto.subtle.digest("SHA-256", buffer).then(function (hash) { return hex(hash); }); } function hex(buffer) { var hexCodes = []; var view = new DataView(buffer); for (var i = 0; i < view.byteLength; i += 4) { // Using getUint32 reduces the number of iterations needed (we process 4 bytes each time) var value = view.getUint32(i) // toString(16) will give the hex representation of the number without padding var stringValue = value.toString(16) // We use concatenation and slice for padding var padding = '00000000' var paddedValue = (padding + stringValue).slice(-padding.length) hexCodes.push(paddedValue); } // Join all the hex strings into one return hexCodes.join(""); } function buildGenerator() { $('#split-num').html(' '); $('canvas').remove(); $('div#qrcode img').remove(); qrcgen.qrcode = new QRCode(document.getElementById("qrcode"), { width : parseInt($('#size').val()), height : parseInt($('#size').val()), correctLevel: getErrLevel(), }); $('#qrcode').css('width', parseInt($('#size').val())+40); $('#qrcode').css('height', parseInt($('#size').val())+40); qrcgen.qrcode.clear(); makeNewCode(); $('div#qrcode img').css('padding', '20px'); $('div#qrcode img').css('background-color', '#fff'); } function _getUTF8Length(sText) { var replacedText = encodeURI(sText).toString().replace(/\%[0-9a-fA-F]{2}/g, 'a'); return replacedText.length + (replacedText.length != sText ? 3 : 0); } function getErrLevel() { return parseInt($('#errlevel').val()); } function getMaxDataPerCode() { var maxPerCode = parseFloat($('#density').val()) * [2331,2953,1273,1663][getErrLevel()]; return Math.floor(maxPerCode); } // returns empty array if any line is longer than length limit function getSplitDataByLine(fullData, lengthLimit) { console.log("splitting by lines data of size " + _getUTF8Length(fullData) + " into chunks of " + lengthLimit); var splits = []; var splitContent = ''; var splitLength = 0; var lineContent = ''; for (var i = 0; i < fullData.length; i++) { var c = fullData.charAt(i); lineContent += c; if (c == '\n') { var lineLength = _getUTF8Length(lineContent); if (lineLength > lengthLimit) { return []; } var combinedLength = _getUTF8Length(splitContent + lineContent); if (combinedLength > lengthLimit) { splits.push(splitContent); splitContent = lineContent; splitLength = lineLength; lineContent = ''; } else { splitContent += lineContent; lineContent = ''; splitLength = combinedLength; } } } var lineLength = _getUTF8Length(lineContent); if (lineLength > lengthLimit) { return []; } if (splitLength + lineLength > lengthLimit) { splits.push(splitContent); splits.push(lineContent); } else { splits.push(splitContent + lineContent); } console.log("split by line into " + splits.length + " codes, with lengths: "); for (var i = 0; i < splits.length; i++) { console.log(i + ": " + _getUTF8Length(splits[i])); } return splits; } function getSplitDataWithinLines(fullData, lengthLimit) { console.log("splitting within lines data of size " + _getUTF8Length(fullData) + " into chunks of " + lengthLimit); var splits = []; var splitContent = ''; var splitLength = 0; var lineContent = ''; for (var i = 0; i < fullData.length; i++) { lineContent += fullData.charAt(i); var combinedLength = _getUTF8Length(splitContent + lineContent); if (combinedLength <= lengthLimit) { splitContent += lineContent; lineContent = ''; splitLength = combinedLength; } else { splits.push(splitContent); splitContent = lineContent; splitLength = _getUTF8Length(lineContent); lineContent = ''; } } var lineLength = _getUTF8Length(lineContent); if (splitLength + lineLength > lengthLimit) { splits.push(splitContent); splits.push(lineContent); } else { splits.push(splitContent + lineContent); } console.log("split within lines into " + splits.length + " codes, with lengths: "); for (var i = 0; i < splits.length; i++) { console.log(i + ": " + _getUTF8Length(splits[i])); } return splits; } // state var dataIsTooBigForSingleCode = false; var lineIsTooBigForSingleCode = false; var userSelectedSplitType = false; var userSelectedSplitWithinLine = false; var splitQrNumShown = 1; var dataForCode = ''; var splitData = []; // see qrcodejs source for these values: they appear to be the maximum // amount of data for the largest renderable QR code... // 1=L (low), 0=M (medium), 3=Q (quartile), 2=H (high) // so in the array below we have max data len for: // M, L, H, Q var qrCodeLimitLengthByErrLevel = [2331,2953,1273,1663]; function makeNewCode() { $('#split-num').html(' '); $('#split-note').html(''); $('#split').hide(); $('#split-change').hide(); dataIsTooBigForSingleCode = false; lineIsTooBigForSingleCode = false; userSelectedSplitType = false; userSelectedSplitWithinLine = false; splitQrNumShown = 1; var elText = document.getElementById("text"); dataForCode = elText.value; sha256(dataForCode).then(function(digest) { $('#full-text-hash').html("Entered data SHA-256: " + digest + "
");
});
var elTextLen = _getUTF8Length(dataForCode);
if (elTextLen > getMaxDataPerCode()) {
dataIsTooBigForSingleCode = true;
splitData = getSplitDataByLine(dataForCode, getMaxDataPerCode());
if (splitData.length == 0) {
lineIsTooBigForSingleCode = true;
splitData = getSplitDataWithinLines(dataForCode, getMaxDataPerCode());
}
} else {
splitData = [dataForCode];
}
showCode();
}
function showCode() {
if (dataIsTooBigForSingleCode) {
if (userSelectedSplitType) {
if (userSelectedSplitWithinLine) {
$('#split-change').html('Split On Lines Instead').show();
$('#split-note').html('There is too much data to show in a single QR code.You have chosen to split within lines into ' + splitData.length + ' QR codes.'); } else { $('#split-change').html('Split Within Lines Instead').show(); $('#split-note').html('There is too much data to show in a single QR code.
You have chosen to split on lines into ' + splitData.length + ' QR codes.'); } } else { if (lineIsTooBigForSingleCode) { $('#split-note').html('There is too much data to show in a single QR code.
The data has been split within lines into ' + splitData.length + ' QR codes.'); $('#split-change').hide(); } else { $('#split-note').html('There is too much data to show in a single QR code.
The data has been split by line into ' + splitData.length + ' QR codes.'); $('#split-change').html('Split Within Lines Instead').show(); } } $('#split-num').html('QR Code ' + splitQrNumShown + ' of ' + splitData.length); $('#split').show(); } else { $('#split').hide(); } qrcgen.qrcode.makeCode(splitData[splitQrNumShown - 1]); sha256(splitData[splitQrNumShown - 1]).then(function(digest) { $('#qrdatahash').html("
Full QR code SHA-256: " + digest + "