This is a working reference for the ESC/POS commands you'll actually use on a receipt printer, with each command's bytes in hex and decimal, what the parameters mean, and the quirks we've hit while building an ESC/POS printing engine. Every command is a short byte sequence, usually starting with ESC (0x1B), GS (0x1D) or DLE (0x10), sent mixed in with your text.
The commands behind almost every receipt:
ESC @1B 40: initialiseESC a n1B 61 n: align left, centre, rightESC E n1B 45 n: bold on or offGS ! n1D 21 n: character sizeESC t n1B 74 n: character tableESC d n1B 64 n: feed n linesGS V 65 n1D 56 41 n: feed and cutESC p 0 25 2501B 70 00 19 FA: open cash drawer
How to read this reference
- Notation:
ESC a nmeans the byteESC, the byte for the lettera, then a parameter byten. - Hex: the bytes you actually send, for example
1B 61 01. - Parameters:
nis a single byte (0–255).nL nHis a 16-bit number sent low byte first: 300 becomes2C 01. - Compatibility: these follow Epson's ESC/POS. Most receipt printers copy the core commands; newer and rarer commands vary on budget clones. Test on your printer.
New to ESC/POS? Start with what is ESC/POS?
Printer setup
| Command | Hex | What it does |
|---|---|---|
ESC @ | 1B 40 | Initialise: clears the buffer and resets styles to defaults. Send it at the start of every job. |
ESC t n | 1B 74 n | Select character table (code page). Common values on Epson-style printers: 0 = PC437, 2 = PC850, 16 = WPC1252, 17 = PC866 (Cyrillic), 19 = PC858 (with €). Numbers differ on some clones; check the self-test page. |
ESC R n | 1B 52 n | Select international character set (swaps a few symbols like # and $ for national variants). |
FS . | 1C 2E | Cancel Chinese (Kanji) character mode. Many printers made for the Chinese market start in double-byte mode and print bytes above 127 as Chinese characters until you send this. |
GS L nL nH | 1D 4C nL nH | Left margin in dots. |
GS W nL nH | 1D 57 nL nH | Printable area width in dots (384 on most 58 mm printers, 576 on 80 mm). |
Field note: if accented letters print as Chinese characters, send FS . before ESC t n. It's the single most common "my code page doesn't work" fix on budget printers.
Text formatting
| Command | Hex | What it does |
|---|---|---|
ESC E n | 1B 45 n | Bold (emphasised): n = 1 on, 0 off. |
ESC - n | 1B 2D n | Underline: 0 off, 1 thin, 2 thick. |
ESC G n | 1B 47 n | Double-strike: looks like bold on many printers. |
ESC M n | 1B 4D n | Font: 0 = Font A (12×24 dots), 1 = Font B (9×17 dots, more characters per line). |
GS ! n | 1D 21 n | Character size. High 4 bits = width multiplier − 1, low 4 bits = height multiplier − 1. 00 normal, 11 double width and height, 01 double height only, 10 double width only. |
ESC ! n | 1B 21 n | Print mode in one byte: add 1 for Font B, 8 for bold, 16 for double height, 32 for double width, 128 for underline. |
GS B n | 1D 42 n | Reverse (white on black): 1 on, 0 off. |
ESC { n | 1B 7B n | Upside-down printing: 1 on, 0 off. |
ESC SP n | 1B 20 n | Extra space to the right of each character, in dots. |
Characters per line depend on the font and paper width. In Font A, a 58 mm printer usually fits 32 characters, an 80 mm printer 48 (some 80 mm models print 42). Double width halves that.
Alignment and position
| Command | Hex | What it does |
|---|---|---|
ESC a n | 1B 61 n | Justification: 0 left, 1 centre, 2 right. Applies from the start of a line, and also to images and barcodes. |
ESC $ nL nH | 1B 24 nL nH | Absolute horizontal position in dots from the left margin. Handy for two-column lines. |
HT | 09 | Horizontal tab to the next tab stop. |
ESC D n1 … NUL | 1B 44 … 00 | Set tab stops (character columns), ended with 00. |
Most libraries build "item … price" lines by padding with spaces rather than tabs, because space padding behaves the same on every printer.
Line spacing and paper feed
| Command | Hex | What it does |
|---|---|---|
LF | 0A | Print the buffer and feed one line. |
ESC d n | 1B 64 n | Print and feed n lines. |
ESC J n | 1B 4A n | Print and feed n dots (fine control). |
ESC 2 | 1B 32 | Default line spacing. |
ESC 3 n | 1B 33 n | Line spacing of n dots. Set it to 0 or 24 when printing images line by line to avoid gaps. |
Cutting and cash drawer
| Command | Hex | What it does |
|---|---|---|
GS V 0 | 1D 56 00 | Full cut at the current position. |
GS V 1 | 1D 56 01 | Partial cut (leaves a small tab). |
GS V 65 n | 1D 56 41 n | Feed n dots to the cutter, then full cut. Prevents cutting through the last line. |
GS V 66 n | 1D 56 42 n | Feed n dots, then partial cut. |
ESC p m t1 t2 | 1B 70 m t1 t2 | Cash drawer pulse. m = 0 for pin 2, 1 for pin 5. On time = t1 × 2 ms, off time = t2 × 2 ms. 1B 70 00 19 FA works for most drawers. |
Details, wiring and printers without a cutter: cut paper and open a cash drawer with ESC/POS.
Barcodes
| Command | Hex | What it does |
|---|---|---|
GS h n | 1D 68 n | Barcode height in dots (default about 162). |
GS w n | 1D 77 n | Module width, 2–6. Use 2 or 3 on 58 mm paper so long codes fit. |
GS H n | 1D 48 n | Human-readable text: 0 none, 1 above, 2 below, 3 both. |
GS k m n data | 1D 6B m n … | Print barcode (format B). m: 65 UPC-A, 67 EAN-13, 68 EAN-8, 69 CODE39, 72 CODE93, 73 CODE128. n = data length. |
CODE128 data must start with a code set selector: {B for normal text, {C for pairs of digits. Example for "ABC-123" in code set B:
1D 6B 49 09 7B 42 41 42 43 2D 31 32 33
// GS k 73 (CODE128), length 9, "{B" + "ABC-123"
QR codes
QR codes use the GS ( k function family. You send four commands: model, size, error correction, store data, then print.
| Step | Hex | Notes |
|---|---|---|
| Model 2 | 1D 28 6B 04 00 31 41 32 00 | Model 2 is the standard QR code. |
| Module size | 1D 28 6B 03 00 31 43 n | n = 1–16 dots per module; 5–8 suits receipts. |
| Error correction | 1D 28 6B 03 00 31 45 n | n = 48 (L), 49 (M), 50 (Q), 51 (H). |
| Store data | 1D 28 6B pL pH 31 50 30 data | pL pH = data length + 3. |
1D 28 6B 03 00 31 51 30 | Prints the stored symbol. |
Some cheap printers ignore GS ( k. If nothing prints, render the QR code as an image instead. See how to print images and QR codes with ESC/POS.
Images
| Command | Hex | What it does |
|---|---|---|
GS v 0 m xL xH yL yH d… | 1D 76 30 m … | Raster bit image. x = bytes per row (width ÷ 8), y = number of dot rows. m = 0 normal, 1 double width, 2 double height, 3 both. Supported by most printers. |
ESC * m nL nH d… | 1B 2A m … | Bit image in vertical strips; m = 33 for 24-dot double density. The fallback for older Epson-compatible printers. |
GS ( L / GS 8 L | 1D 28 4C … | Graphics functions on newer printers (store and print graphics, NV logos). |
In image data, each bit is one dot: 1 = black, 0 = white, most significant bit on the left.
Status and identification
| Command | Hex | Reply |
|---|---|---|
DLE EOT 1 | 10 04 01 | Printer status byte (drawer, online/offline). |
DLE EOT 2 | 10 04 02 | Offline cause (cover open, feed button, paper end). |
DLE EOT 4 | 10 04 04 | Paper sensor (near-end, end). |
GS I n | 1D 49 n | Printer ID. n = 1 model ID, 2 type ID (tells you about cutter and multi-byte fonts), 3 firmware; 66 manufacturer name, 67 model name on printers that support it. |
None of these print or feed paper, which makes them safe for detecting a printer. Raw Print sends DLE EOT and GS I during setup to learn the model, maker and whether there's a cutter, before printing anything. Be aware that many cheap Bluetooth printers never reply, so treat silence as "unknown", not "error".
A complete receipt in bytes
Here is a short receipt built from the commands above, in Python:
ESC, GS = b"\x1b", b"\x1d" receipt = ( ESC + b"@" # initialise + b"\x1c\x2e" # FS . cancel Chinese mode + ESC + b"t\x13" # code page 19 = PC858 + ESC + b"a\x01" # centre + GS + b"!\x11" + b"CORNER CAFE\n" # double size + GS + b"!\x00" + b"12 High Street\n\n" + ESC + b"a\x00" # left + b"1 x Flat white 3.50\n" + b"2 x Croissant 5.00\n" + ESC + b"E\x01" + b"TOTAL 8.50\n" + ESC + b"E\x00" + ESC + b"d\x03" # feed 3 lines + GS + b"V\x41\x10" # feed 16 dots, full cut + ESC + b"p\x00\x19\xfa" # open drawer (pin 2) ) # write `receipt` to the printer: socket to port 9100, USB, serial or Bluetooth
Lines are padded to 32 characters for a 58 mm printer. Accented text must be encoded in the selected code page (here "café".encode("cp858")), never as UTF-8.
You don't have to build bytes by hand. Libraries for every language wrap these commands. See the best ESC/POS libraries, ESC/POS in JavaScript and ESC/POS in PHP, Java, C# and Flutter.
Building a web POS? Encode the receipt in the browser and hand the bytes to an Android print app with a rawbt:base64, link; Raw Print sends them to the printer untouched. Details in why your web POS needs a printing engine.
Commands that differ between printers
- Code page numbers after 19 vary a lot. Always confirm with the self-test page.
- QR codes (
GS ( k) are missing on some very cheap printers. - Cutting commands are ignored on printers without a cutter (no harm done).
- Status replies are often missing over Bluetooth on budget models.
- Star printers in Star mode use different commands entirely; switch them to ESC/POS emulation or use StarPRNT.
Testing without a printer? Try an ESC/POS emulator or virtual printer.
Frequently asked questions
What is the ESC/POS command to cut paper?
GS V 0 (1D 56 00) cuts fully; GS V 65 n (1D 56 41 n) feeds n dots first and then cuts, which avoids cutting through the last line.
How do I make text bigger in ESC/POS?
Use GS ! n. 1D 21 11 doubles width and height; 1D 21 00 returns to normal. Larger multipliers go up to 8×.
Why does my ESC/POS printer print Chinese characters?
It's in Chinese double-byte mode, so bytes above 127 become Chinese characters. Send FS . (1C 2E), then select your code page with ESC t n.
Where is the official ESC/POS command reference?
Epson publishes the ESC/POS Command Reference on its website for TM-series printers. Clone printers usually ship a programming manual for their own variant.