Blog

ESC/POS Commands: Reference With Hex Codes and Examples

25 October 2026 · 9 min read · By the Raw Print team

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: initialise
  • ESC a n 1B 61 n: align left, centre, right
  • ESC E n 1B 45 n: bold on or off
  • GS ! n 1D 21 n: character size
  • ESC t n 1B 74 n: character table
  • ESC d n 1B 64 n: feed n lines
  • GS V 65 n 1D 56 41 n: feed and cut
  • ESC p 0 25 250 1B 70 00 19 FA: open cash drawer

How to read this reference

  • Notation: ESC a n means the byte ESC, the byte for the letter a, then a parameter byte n.
  • Hex: the bytes you actually send, for example 1B 61 01.
  • Parameters: n is a single byte (0–255). nL nH is a 16-bit number sent low byte first: 300 becomes 2C 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

CommandHexWhat it does
ESC @1B 40Initialise: clears the buffer and resets styles to defaults. Send it at the start of every job.
ESC t n1B 74 nSelect 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 n1B 52 nSelect international character set (swaps a few symbols like # and $ for national variants).
FS .1C 2ECancel 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 nH1D 4C nL nHLeft margin in dots.
GS W nL nH1D 57 nL nHPrintable 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

CommandHexWhat it does
ESC E n1B 45 nBold (emphasised): n = 1 on, 0 off.
ESC - n1B 2D nUnderline: 0 off, 1 thin, 2 thick.
ESC G n1B 47 nDouble-strike: looks like bold on many printers.
ESC M n1B 4D nFont: 0 = Font A (12×24 dots), 1 = Font B (9×17 dots, more characters per line).
GS ! n1D 21 nCharacter 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 ! n1B 21 nPrint 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 n1D 42 nReverse (white on black): 1 on, 0 off.
ESC { n1B 7B nUpside-down printing: 1 on, 0 off.
ESC SP n1B 20 nExtra 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

CommandHexWhat it does
ESC a n1B 61 nJustification: 0 left, 1 centre, 2 right. Applies from the start of a line, and also to images and barcodes.
ESC $ nL nH1B 24 nL nHAbsolute horizontal position in dots from the left margin. Handy for two-column lines.
HT09Horizontal tab to the next tab stop.
ESC D n1 … NUL1B 44 … 00Set 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

CommandHexWhat it does
LF0APrint the buffer and feed one line.
ESC d n1B 64 nPrint and feed n lines.
ESC J n1B 4A nPrint and feed n dots (fine control).
ESC 21B 32Default line spacing.
ESC 3 n1B 33 nLine spacing of n dots. Set it to 0 or 24 when printing images line by line to avoid gaps.

Cutting and cash drawer

CommandHexWhat it does
GS V 01D 56 00Full cut at the current position.
GS V 11D 56 01Partial cut (leaves a small tab).
GS V 65 n1D 56 41 nFeed n dots to the cutter, then full cut. Prevents cutting through the last line.
GS V 66 n1D 56 42 nFeed n dots, then partial cut.
ESC p m t1 t21B 70 m t1 t2Cash 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

CommandHexWhat it does
GS h n1D 68 nBarcode height in dots (default about 162).
GS w n1D 77 nModule width, 2–6. Use 2 or 3 on 58 mm paper so long codes fit.
GS H n1D 48 nHuman-readable text: 0 none, 1 above, 2 below, 3 both.
GS k m n data1D 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.

StepHexNotes
Model 21D 28 6B 04 00 31 41 32 00Model 2 is the standard QR code.
Module size1D 28 6B 03 00 31 43 nn = 1–16 dots per module; 5–8 suits receipts.
Error correction1D 28 6B 03 00 31 45 nn = 48 (L), 49 (M), 50 (Q), 51 (H).
Store data1D 28 6B pL pH 31 50 30 datapL pH = data length + 3.
Print1D 28 6B 03 00 31 51 30Prints 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

CommandHexWhat 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 L1D 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

CommandHexReply
DLE EOT 110 04 01Printer status byte (drawer, online/offline).
DLE EOT 210 04 02Offline cause (cover open, feed button, paper end).
DLE EOT 410 04 04Paper sensor (near-end, end).
GS I n1D 49 nPrinter 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.