Skip to content

ESC Commands

ESC is a binary printer command language widely used by thermal receipt and label printers.

ESC commands are hexadecimal byte sequences. Each command generally starts with a specific control code.

[Control code] [Function code] [Parameters...]
Control codeHexNamePurpose
ESC0x1BEscapeStandard control commands
GS0x1DGroup SeparatorGraphics/Advanced features
DLE0x10Data Link EscapeReal-time status commands
FS0x1CFile SeparatorChinese character mode commands
LF0x0ALine FeedLine feed

Wake the printer from sleep.

Hex: 00 00 00 00 00 00 00 00

Send eight null bytes to wake the printer.

Enable the printer so it can receive print data.

Hex: 10 FF 20 00

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

ESC @
Hex: 1B 40

End the current print job.

Hex: 1B 40 10 FF FE 01

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
xL xHHorizontal byte count (low byte, high byte)
yL yHVertical dot count (low byte, high byte)
DataImage bitmap data
m valueDescription
0Normal printing
1Double-width printing
2Double-height printing
3Double-width and double-height printing

Printers that support compression can receive image data in compressed mode.

Hex: 1F 00 [Width high byte] [Width low byte] [Height high byte] [Height low byte] [Data length 4 Bytes] [Compressed data]

The SDK supports a configurable binarization threshold. The default is 190.

Threshold rangeEffect
0-127Darker image
128-190Normal (recommended)
191-255Lighter image

Position the paper at the next label (for label paper mode).

Hex: 10 FF 04

Automatically learn/detect the gap between labels.

Hex: 10 FF 30 F2 31

Feed the paper forward by the specified number of dots.

ESC J n
Hex: 1B 4A n
ParameterDescription
nFeed distance in dots (0-255)
Hex: 10 FF F0 [Dot count low byte] [Dot count high byte]

Feed the paper backward by the specified number of dots.

Hex: 10 FF F1 [Dot count low byte] [Dot count high byte]

Set the horizontal print starting position.

Hex: 10 FF 12 [Position value]

Set the printer’s paper type.

Hex: 10 FF 10 03 [Type]
Type valuePaper type
0Fanfold black mark paper
1Continuous roll paper
2Adhesive gap labels
3Punched paper
4Tattoo paper
5Tattoo paper (anti-wrinkle mode)
6Transparent black mark paper

For models such as Q1, Q2, Q3, D11, D30, B21, and B22.

Hex: 10 FF 40 F4 [Type]
Type valuePaper type
0Gap paper
1Black mark paper
2Continuous paper
Hex: 10 FF 40 F3

Return values:

  • 0x01 - Black mark paper
  • 0x02 - Continuous paper
  • Other values - Gap paper

Set the printer’s print density.

Hex: 10 FF 10 00 [Density value]
Density valueDescription
0Low density
1Medium density
2High density

Set the automatic shutdown timeout.

Hex: 10 FF 10 0A [Time low byte] [Time high byte]
ParameterDescription
TimeShutdown timeout (minutes), 0 disables automatic shutdown
Hex: 10 FF 10 0B

Set the Bluetooth communication type (required for printers that support compression).

Hex: 10 FF 40 F1

Set the printer’s current time (supported on some models).

Hex: 10 FF 40 A0 [Year] [Month] [Day] [Hour] [Minute] [Second]

Cut the paper immediately.

Hex: 1D 56 00

Feed a fixed distance and then cut the paper. The firmware determines the feed distance.

Hex: 1D 56 42 00
CommandHexDescription
GS V 01D 56 00Full cut
GS V 11D 56 01Partial cut
GS V 66 n1D 56 42 nFeed n lines, then cut

Draw a straight line.

Hex: 10 FF 21 [X Low] [X High] [Y Low] [Y High] [Width low byte] [Width high byte] [Height low byte] [Height high byte]
ParameterDescription
XStarting X coordinate
YStarting Y coordinate
WidthLine width
HeightLine height

Query all printer information.

Hex: 10 FF 00 FF

Query the current printer status.

Hex: 10 FF F9

Query the printer’s battery level.

Hex: 10 FF 50 00
Hex: 10 FF 50 11
Hex: 10 FF 30 00
Hex: 10 FF 20 00
Hex: 10 FF 30 F0
Hex: 10 FF 20 F0
Hex: 10 FF 50 14
Hex: 10 FF 30 02

Some printers support NFC tags.

Hex: 10 FF A0 00
Hex: 10 FF A0 01
Hex: 10 FF A0 02
Hex: 10 FF A0 03

Some printers support grayscale printing.

Hex: 10 FF E1 03

Print an image in grayscale mode for a wider range of gray levels.


The printer sends unsolicited status information to the application in certain situations.

When an abnormal condition occurs, the printer sends a two-byte status message.

HeaderStatus typeMeaning
0xFF0x00Printer normal
0xFF0x01Overheated
0xFF0x02Cover open
0xFF0x04Out of paper
0xFF0x08Low voltage

The device sends a report when the detected paper does not match the configured paper type.

HeaderStatus typeMeaning
0xFE0x01Fanfold black mark paper
0xFE0x02Continuous roll paper
0xFE0x03Adhesive gap labels

Reports sent when the user cancels a print job.

HeaderStatus typeMeaning
0xFD0x01Start clearing the current page’s print job
0xFD0x02Current print job cleared

Recommended print sequence:

  1. Wake the printer - Send the wakeup command
  2. Enable the printer - Enable printing
  3. Print the image - Send image data
  4. Position the paper - Advance to the next label (not needed for continuous paper)
  5. End the print job - Finish printing
00 00 00 00 00 00 00 00 # Wake the printer
10 FF 20 00 # Enable the printer
10 FF 10 00 01 # Set medium density
10 FF 10 03 02 # Set adhesive gap labels
1D 76 30 00 ... # Print image data
10 FF 04 # Position the paper
1B 40 10 FF FE 01 # End the print job

Each language SDK wraps ESC command construction. See the following guides for usage:

Complete ESC command reference (PDF)