ESC/POS command reference › ESC !
ESC ! (1B 21): set font, bold, size and underline in one byte
An older command that sets five styles at once from the bits of n. Handy, but it overwrites whatever you set before with the single-purpose commands.
| ASCII | ESC ! n |
| Hex | 1B 21 n |
| Decimal | 27 33 n |
Parameters
n | bit 0 (0x01) font B, bit 3 (0x08) bold, bit 4 (0x10) double height, bit 5 (0x20) double width, bit 7 (0x80) underline. Add the values you want. |
What it does
escpos-php's selectPrintMode() takes OR-ed MODE_* constants with exactly these values (FONT_B 1, EMPHASIZED 8, DOUBLE_HEIGHT 16, DOUBLE_WIDTH 32, UNDERLINE 128) and notes that mode 0 "has a similar effect to running initialize()" for text style.
python-escpos uses ESC ! 0x10, 0x20 and 0x30 for its "2h", "2w" and "2x" sizes.
Because every bit is written each time, ESC ! turns off anything whose bit is 0: bold from ESC E, underline from ESC -, and a size from GS !. It only goes up to double size; use GS ! for 3x to 8x.
Example
Four values of n.
1B 21 08 62 6F 6C 64 20 28 30 78 30 38 29 0A 1B 21 30 32 78 20 28 30 78 33 30 29 0A 1B 21 81 66 6F 6E 74 20 42 20 2B 20 75 6E 64 65 72 6C 69 6E 65 20 28 30 78 38 31 29 0A 1B 21 00 61 6C 6C 20 6F 66 66 20 28 30 78 30 30 29 0A
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
| Command | What it does | Bytes |
|---|---|---|
| ESC ! | Print mode: font A, bold | 1B 21 08 |
| Text | "bold (0x08)" | 62 6F 6C 64 20 28 30 78 30 38 29 |
| ESC ! | Print mode: font A, double height, double width | 1B 21 30 |
| Text | "2x (0x30)" | 32 78 20 28 30 78 33 30 29 |
| ESC ! | Print mode: font B, underline | 1B 21 81 |
| Text | "font B + underline (0x81)" | 66 6F 6E 74 20 42 20 2B 20 75 6E 64 65 72 6C 69 6E 65 20 28 30 78 38 31 … |
| ESC ! | Print mode: font A | 1B 21 00 |
| Text | "all off (0x00)" | 61 6C 6C 20 6F 66 66 20 28 30 78 30 30 29 |
Sending it from code
JavaScript (bytes)
const mode = (n) => [0x1b, 0x21, n];
mode(0x08 | 0x30); // bold, double width and heightPHP with escpos-php
$printer->selectPrintMode(Printer::MODE_EMPHASIZED | Printer::MODE_DOUBLE_WIDTH); // 1B 21 28
$printer->selectPrintMode(); // 1B 21 00Python (raw bytes)
data = b"\x1b\x21\x38" + b"BIG BOLD\n" + b"\x1b\x21\x00"
Common mistakes
- Setting bold with
ESC E 1, then size withESC ! 0x30: bold is now off, because bit 3 was 0. - Expecting 3x text from
ESC !. Its size bits only double.
Related commands
GS !: double width and height text, up to 8xESC E: bold text on a receipt printerESC -: underline text on a receipt printer
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).