Thermalink

ESC/POS command reference › GS ( k

GS ( k (1D 28 6B): print a QR code on a receipt printer

A QR code takes five GS ( k commands: choose the model, set the module size, set error correction, store the data, print it.

ASCIIGS ( k pL pH cn fn ...
Hex1D 28 6B pL pH 31 fn ...
Decimal29 40 107 pL pH 49 fn ...

Parameters

pL pHlength of what follows them: pL + pH × 256. For the store command that is the data length + 3.
cn0x31 (49) = QR code.
fn 0x41 (65)model: 1D 28 6B 04 00 31 41 32 00 selects model 2, the usual QR code that phone cameras read.
fn 0x43 (67)module size: 1D 28 6B 03 00 31 43 n, n = 1 to 16 dots per module.
fn 0x45 (69)error correction: 1D 28 6B 03 00 31 45 n, n = 48 L, 49 M, 50 Q, 51 H.
fn 0x50 (80)store: 1D 28 6B pL pH 31 50 30 d1...dk.
fn 0x51 (81)print: 1D 28 6B 03 00 31 51 30.

What it does

The printer builds the QR code from your data, so you send a few dozen bytes instead of an image. escpos-php's qrCode() and Thermalink both send these five commands in this order. Thermalink uses model 2 and error correction M on the BIXOLON.

The module size sets the printed size. A short URL is a version 2 or 3 symbol, 25 to 29 modules wide, so module size 6 gives about 150 to 175 dots (19 to 22 mm at 203 dpi). escpos-php allows 1 to 16 and defaults to 3.

Higher error correction survives smudges but makes the symbol bigger. L or M is fine for receipts.

Example

Model 2, module size 6, error correction M, centered.

1B 61 01 1D 28 6B 04 00 31 41 32 00 1D 28 6B 03 00 31 43 06 1D 28 6B 03 00 31 45 31 1D 28 6B 1D 00 31 50 30 68 74 74 70 73 3A 2F 2F 65 78 61 6D 70 6C 65 2E 63 6F 6D 2F 72 2F 31 30 34 32 1D 28 6B 03 00 31 51 30 0A 53 63 61 6E 20 66 6F 72 20 79 6F 75 72 20 65 2D 72 65 63 65 69 70 74 0A 1B 61 00

Preview drawn in your browser by the ESC/POS viewer's engine on 80 mm paper. Letters use a similar monospace font, not the printer's own. Open this example in the viewer to edit the bytes.

How the viewer decodes these bytes
CommandWhat it doesBytes
ESC aAlign center1B 61 01
GS ( kQR: model 21D 28 6B 04 00 31 41 32 00
GS ( kQR: module size 6 dots1D 28 6B 03 00 31 43 06
GS ( kQR: error correction M1D 28 6B 03 00 31 45 31
GS ( kQR: store 26 bytes1D 28 6B 1D 00 31 50 30 68 74 74 70 73 3A 2F 2F 65 78 61 6D 70 6C 65 2E …
GS ( kQR: print, version 2, 25×25 modules, 150 dots, error correction M, 26 bytes1D 28 6B 03 00 31 51 30
Text"Scan for your e-receipt"53 63 61 6E 20 66 6F 72 20 79 6F 75 72 20 65 2D 72 65 63 65 69 70 74
ESC aAlign left1B 61 00

Sending it from code

JavaScript (bytes)

function qr(text, size = 6) {
  const d = new TextEncoder().encode(text), k = d.length + 3;
  return [0x1d,0x28,0x6b,4,0,0x31,0x41,0x32,0, 0x1d,0x28,0x6b,3,0,0x31,0x43,size,
          0x1d,0x28,0x6b,3,0,0x31,0x45,0x31, 0x1d,0x28,0x6b,k & 255,k >> 8,0x31,0x50,0x30, ...d,
          0x1d,0x28,0x6b,3,0,0x31,0x51,0x30];
}

PHP with escpos-php

$printer->qrCode("https://example.com/r/1042", Printer::QR_ECLEVEL_M, 6);

Python (raw bytes)

def qr(text, size=6):
    d = text.encode(); k = len(d) + 3
    return (b"\x1d(k\x04\x001A2\x00" + b"\x1d(k\x03\x001C" + bytes([size])
            + b"\x1d(k\x03\x001E1" + b"\x1d(k" + bytes([k % 256, k // 256]) + b"1P0" + d
            + b"\x1d(k\x03\x001Q0")

Common mistakes

Related commands

Sources

I wrote this page from the open-source libraries above, Thermalink's own output and tests on my BIXOLON printer. It is not copied from Epson's manual. For model-specific details see Epson's official ESC/POS reference or your printer maker's manual. Last checked 22 November 2026.

Building receipts byte by byte? Thermalink lets a web app send the receipt as JSON and prints it silently, with QR codes, logos, cut and cash drawer ($49 one-time).