Thermalink

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.

ASCIIESC a n
Hex1B 61 n
Decimal27 97 n

Parameters

n0 = 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
CommandWhat it doesBytes
ESC aAlign center1B 61 01
Text"Centered"43 65 6E 74 65 72 65 64
ESC aAlign right1B 61 02
Text"Right"52 69 67 68 74
ESC aAlign left1B 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 01

Python (raw bytes)

data = b"\x1b\x61\x01" + b"Centered\n" + b"\x1b\x61\x00"

Common mistakes

Related commands

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).