ESC/POS command reference › ESC a
ESC a (1B 61): center or right-align text on a receipt printer
1B 61 01 centers, 1B 61 02 right-aligns, 1B 61 00 goes back to left.
| ASCII | ESC a n |
| Hex | 1B 61 n |
| Decimal | 27 97 n |
Parameters
n | 0 = left, 1 = center, 2 = right. The viewer also accepts 0x30 to 0x32 (ASCII "0" to "2"). |
What it does
Alignment applies to whole lines, so send it before the first character of the line. Sent in the middle of a line, it takes effect from the next line; the viewer warns about this.
It also positions barcodes, QR codes and raster images. Thermalink centers its logo and QR blocks by sending ESC a 1 before the image and ESC a 0 after it.
escpos-php's setJustification() accepts JUSTIFY_LEFT (0), JUSTIFY_CENTER (1) and JUSTIFY_RIGHT (2).
Example
Center, right, then left again.
1B 61 01 43 65 6E 74 65 72 65 64 0A 1B 61 02 52 69 67 68 74 0A 1B 61 00 4C 65 66 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 a | Align center | 1B 61 01 |
| Text | "Centered" | 43 65 6E 74 65 72 65 64 |
| ESC a | Align right | 1B 61 02 |
| Text | "Right" | 52 69 67 68 74 |
| ESC a | Align left | 1B 61 00 |
| Text | "Left" | 4C 65 66 74 |
Sending it from code
JavaScript (bytes)
const align = { left: [0x1b, 0x61, 0], center: [0x1b, 0x61, 1], right: [0x1b, 0x61, 2] };PHP with escpos-php
$printer->setJustification(Printer::JUSTIFY_CENTER); // 1B 61 01Python (raw bytes)
data = b"\x1b\x61\x01" + b"Centered\n" + b"\x1b\x61\x00"
Common mistakes
- Switching alignment halfway through a line to right-align a price. Use spaces (or tabs) to push the price right instead; alignment is per line.
- Forgetting
ESC a 0after a centered logo, so the item lines come out centered too.
Related commands
GS !: double width and height text, up to 8xGS v 0: print a logo or image on a receipt printerGS ( k: print a QR code on a receipt printer
Sources
- escpos-php,
Printer.php(MIT licence) - Thermalink agent output, printed on a BIXOLON SRP-352plusIII (Windows 11, USB)
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).