ESC/POS command reference › ESC 3
ESC 3 (1B 33) and ESC 2 (1B 32): receipt line spacing
1B 33 n sets the distance from one line to the next. 1B 32 goes back to the default.
| ASCII | ESC 3 n |
| Hex | 1B 33 n |
| Decimal | 27 51 n |
Parameters
n | 0 to 255 motion units. The viewer treats one unit as one dot and uses 30 dots for ESC 2. |
What it does
Tighter spacing fits more lines on less paper; looser spacing gives a lighter look. The value lasts until ESC 2, another ESC 3 or ESC @.
The unit is printer-dependent. escpos-php's setLineSpacing($height) documents it as "the height of each line, in dots" (1 to 255) and writes ESC 2 when called with no value. python-escpos lists ESC 3 under 1/180-inch spacing. Both are true for some printers: the unit is set by GS P and differs between models, so test the number on your printer.
If n is smaller than the character height (24 dots for font A), lines overlap on paper.
Example
n = 24, then n = 64, then ESC 2.
1B 33 18 54 69 67 68 74 20 28 32 34 29 0A 54 69 67 68 74 20 28 32 34 29 0A 1B 33 40 4C 6F 6F 73 65 20 28 36 34 29 0A 4C 6F 6F 73 65 20 28 36 34 29 0A 1B 32 44 65 66 61 75 6C 74 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 3 | Line spacing 24 dots | 1B 33 18 |
| Text | "Tight (24)" | 54 69 67 68 74 20 28 32 34 29 |
| Text | "Tight (24)" | 54 69 67 68 74 20 28 32 34 29 |
| ESC 3 | Line spacing 64 dots | 1B 33 40 |
| Text | "Loose (64)" | 4C 6F 6F 73 65 20 28 36 34 29 |
| Text | "Loose (64)" | 4C 6F 6F 73 65 20 28 36 34 29 |
| ESC 2 | Default line spacing | 1B 32 |
| Text | "Default" | 44 65 66 61 75 6C 74 |
Sending it from code
JavaScript (bytes)
const spacing = (n) => [0x1b, 0x33, n], defaultSpacing = [0x1b, 0x32];PHP with escpos-php
$printer->setLineSpacing(24); // 1B 33 18
$printer->setLineSpacing(); // 1B 32Python (raw bytes)
data += b"\x1b\x33\x18" # 24 units
data += b"\x1b\x32" # default
Common mistakes
- Copying a value from code written for another printer. The same
ncan be a different distance on a model with a different motion unit. - Setting
nbelow the font height and getting overlapping lines.
Related commands
ESC d: print and feed paperGS !: double width and height text, up to 8xESC @: initialize the 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).