Skip to content

ESC/POS Commands

ESC/POS is a thermal printer command set developed by Epson. It is the industry standard for POS printers and offers the best compatibility.

Like ESC, ESC/POS uses binary control commands. Its broad industry adoption makes it the preferred choice for receipt printing.

FeatureESCESC/POS
Command formatBinaryBinary
Industry standardNo✅ Epson standard
CompatibilityAverageExcellent
Primary usePortable printersPoint-of-sale systems

Initialize the printer, clear the print buffer, and restore default settings.

ESC @
Hex: 1B 40

Print the buffer contents and advance to the next line.

LF
Hex: 0A

Print the buffer contents and return the carriage.

CR
Hex: 0D

Feed the paper forward by n units.

ESC J n
Hex: 1B 4A n
ParameterRangeDescription
n0-255Feed distance in dots

Feed the paper forward by n lines.

ESC d n
Hex: 1B 64 n
ParameterRangeDescription
n0-255Number of lines to feed

Set the character width and height multipliers.

GS ! n
Hex: 1D 21 n

Bit settings for parameter n:

  • Bits 0–2: Horizontal multiplier (0–7 represents 1–8 times)
  • Bits 4–6: Vertical multiplier (0–7 represents 1–8 times)
n valueEffect
0x00Normal size (1x1)
0x10Double height (1x2)
0x01Double width (2x1)
0x11Double width and height (2x2)
0x22Triple width and height (3x3)
0x778× width and height (8x8)

Example:

1D 21 11 // Set width and height multipliers

Set text alignment.

ESC a n
Hex: 1B 61 n
n valueAlignment
0Left aligned
1Centered
2Right aligned

Example:

1B 61 01 // Center aligned

Enable or disable bold mode.

ESC E n
Hex: 1B 45 n
n valueEffect
0Disable bold
1Enable bold

Set underline mode.

ESC - n
Hex: 1B 2D n
n valueEffect
0Disable underline
11-dot underline
22-dot underline

Set black/white reverse printing mode.

GS B n
Hex: 1D 42 n
n valueEffect
0Disable reverse printing
1Enable reverse printing

Select the font type.

ESC M n
Hex: 1B 4D n
n valueFont
0Font A (12x24)
1Font B (9x17)

Set the line spacing.

ESC 3 n
Hex: 1B 33 n
ParameterDescription
nLine spacing (dots)

Restore the default line spacing.

ESC 2
Hex: 1B 32

Set the barcode height.

GS h n
Hex: 1D 68 n
ParameterRangeDescription
n1-255Barcode height (dots)

Example:

1D 68 50 // Set barcode height to 80 Dots

Set the barcode width.

GS w n
Hex: 1D 77 n
ParameterRangeDescription
n2-6Barcode width multiplier

Set the printing position of human-readable interpretation (HRI) characters for the barcode.

GS H n
Hex: 1D 48 n
n valuePosition
0Do not print
1Above barcode
2Below barcode
3Above and below

Print a one-dimensional barcode.

GS k m n [Data]
Hex: 1D 6B m n [Data]
ParameterDescription
mBarcode type
nData length
m valueBarcode typeData requirements
0UPC-A11-12 digits
1UPC-E6-8 digits
2EAN-1312-13 digits
3EAN-87-8 digits
4CODE39Alphanumeric
5ITFEven number of digits
6CODABARDigits + A-D
65UPC-A11-12 digits
66UPC-E6-8 digits
67EAN-1312-13 digits
68EAN-87-8 digits
69CODE39Alphanumeric
70ITFEven number of digits
71CODABARDigits + A-D
72CODE93ASCII
73CODE128ASCII (recommended)

Example:

1D 68 60 // Set barcode height 96
1D 77 03 // Set barcode width 3
1D 48 02 // HRI Print below
1D 6B 49 0D 7B 42 31 32 33 34 35 36 37 38 39 30 31 32 33
// Print CODE128 Barcode "1234567890123"

QR code printing requires several commands in sequence:

GS ( k pL pH cn fn n
Hex: 1D 28 6B 03 00 31 43 n
ParameterRangeDescription
n1-16Cell size (dots)
GS ( k pL pH cn fn n
Hex: 1D 28 6B 03 00 31 45 n
n valueError correction levelError correction capacity
48 (0x30)L7%
49 (0x31)M15%
50 (0x32)Q25%
51 (0x33)H30%
GS ( k pL pH cn fn m [Data]
Hex: 1D 28 6B pL pH 31 50 30 [Data]
ParameterDescription
pL pHData length + 3 (low byte, high byte)
DataQR code content
GS ( k pL pH cn fn m
Hex: 1D 28 6B 03 00 31 51 30

Complete example:

1D 28 6B 03 00 31 43 06 // Set cell size to 6
1D 28 6B 03 00 31 45 31 // Set error correction level to M
1D 28 6B 13 00 31 50 30 68 74 74 70 73 3A 2F 2F 65 78 61 6D 70 6C 65 2E 63 6F 6D
// Store data "https://example.com"
1D 28 6B 03 00 31 51 30 // Print a QR code

Perform a full cut.

GS V m
Hex: 1D 56 m
m valueEffect
0Full cut
1Partial cut

Feed n lines and then cut the paper.

GS V m n
Hex: 1D 56 m n
m valueEffect
65 (0x41)Feed n lines, then full cut
66 (0x42)Feed n lines, then partial cut

Example:

1D 56 42 03 // Feed paper 3 Lines, then cut

Print a raster bitmap image.

GS v 0 m xL xH yL yH [Data]
Hex: 1D 76 30 m xL xH yL yH [Data]
ParameterDescription
mPrint mode (0=Normal, 1=Double width, 2=Double height, 3=Double width and height)
xL xHHorizontal byte count (Width/8)
yL yHVertical dot count (Height)
DataBitmap data

Open the cash drawer.

ESC p m t1 t2
Hex: 1B 70 m t1 t2
ParameterDescription
mCash drawer pin (0 or 1)
t1On time (t1 × 2ms)
t2Off time (t2 × 2ms)

Example:

1B 70 00 19 FA // Open the cash drawer

Query printer status in real time.

DLE EOT n
Hex: 10 04 n
n valueQuery target
1Printer status
2Offline status
3Error status
4Paper status

1B 40 // Initialize the printer
// Print title
1B 61 01 // Centered
1D 21 11 // Double width and height
[GBK: XX Convenience store]
0A
// Print subtitle
1D 21 00 // Restore normal size
[GBK: Order number: 20240115001]
0A
[GBK: ================================]
0A
// Print product list
1B 61 00 // Left aligned
[GBK: Cola 500ml x2 ¥6.00]
0A
[GBK: Potato chips Large pack x1 ¥8.50]
0A
[GBK: Mineral water x3 ¥4.50]
0A
[GBK: --------------------------------]
0A
// Print total
1D 21 10 // Double height
1B 45 01 // Bold
[GBK: Total: ¥19.00]
1B 45 00 // Disable bold
1D 21 00 // Restore normal mode
0A 0A
// Print a QR code
1B 61 01 // Centered
1D 28 6B 03 00 31 43 05 // QR code cell size
1D 28 6B 03 00 31 45 31 // Error correction level M
1D 28 6B ... 31 50 30 [URLData] // Store data
1D 28 6B 03 00 31 51 30 // Print a QR code
[GBK: Scan to follow the store]
0A
// Print a barcode
1D 68 50 // Barcode height
1D 77 02 // Barcode width
1D 48 02 // HRI Position
1D 6B 49 ... [Barcode data] // Print a barcode
// Feed and cut
1B 64 03 // Feed paper 3 Lines
1D 56 42 00 // Cut paper
┌─────────────────────────────┐
│ XX Convenience store │ ← Centered, Double width and height
│ Order number: 20240115001 │ ← Centered, Normal size
│ ════════════════════════════│
│ Cola 500ml x2 ¥6.00 │ ← Left aligned
│ Potato chips Large pack x1 ¥8.50 │
│ Mineral water x3 ¥4.50 │
│ ────────────────────────────│
│ Total: ¥19.00 │ ← Double height, Bold
│ │
│ [QR code] │ ← Centered
│ Scan to follow the store │
│ │
│ ||||||||||||||| │ ← Barcode
│ 6901234567890 │
└─────────────────────────────┘

For ESC/POS usage in each language, see:

Complete ESC/POS command reference (PDF)