Standard ESC/POS Codes for Termal Printers and Cash Drawers
This page explains various important standard printer control codes, so called ESC/POS or ESC/P codes, that were introduced by Epson back in the 90th.
Those standard Epson ESC/POS codes are used to control all kinds of termal printers, even controlling automatic cash drawers and paper cutters in order to fully automate the cashier and invoice printing process at the point of sale.
ESC/P codes can be used to not only control how a termal printer prints an invoice, but also which character sets, to define the max character width, set the font size and trigger to print a stored logo image at a specific position.
Finally, ESC/P codes can be used to automatically cut the paper of the invoice and to open the cash drawer.
All codes are given as hex codes that can be entered directly into the TabShop ESC/POS settings fields, separated by a comma.
Mind that all those ESC/POS commands are highly depending on your printer model and how much each model and vendor implemented the original Epson ESC/POS specifications. By trying out some codes below you will quickly find out which codes open your drawer, enable the cutter or print a logo on your termal printer model and which ones are not supported by your model.
ESC/P Command | Hex Command | Description |
---|---|---|
ESC @ | 1B,40 | Initialize the ESC/POS printer |
FS p n m | 1C,70,01,00 | Quick print a logo that is stored within the memory of your termal printer, n=1-255, m depends on printer model. |
ESC i | 1B,69 | Epson partial cut of the paper, one point left uncut. |
ESC m | 1B,6D | Epson partial cut of the paper, three points left uncut. |
ESC p 0 | 1B,70,00 | Epson cash drawer 1 open command |
ESC p 1 | 1B,70,01 | Epson cash drawer 2 open command |
ESC x 1 | 1B,78,01 | M80 cash drawer 1 open command |
ESC x 2 | 1B,78,02 | M80 cash drawer 2 open command |
LF | 0A | Line feed |
HT | 09 | Print a horizontal tabulator |
ESC d n | 1B 64 n | Print and feed n lines |
ESC e n | 1B 65 n | Print and reverse feed n lines |
ESC 2 | 1B 32 | Set default line spacing |
ESC 3 n | 1B 33 n | Sets the line spacing to n times (vertical or horizontal motion unit). |
ESC - n | 1B 2D n | Turn underline mode on/off, 0 is off, 1 is one dot line, 2 is two dot line |
ESC SP n | 1B 20 n | Sets the right-side character spacing to n times (horizontal or vertical motion unit). |
ESC ! n | 1B 21 n | Enable or disable print mode such as bold, italic or underline (n=00 off, n=10 double high, n=08 bold, n=40 italic). |
FS ! n | 1C 21 n | Select print mode for Kanji characters (n = range from 0 - 255). |
FS & | 1C 26 | Select Kanji character mode. |
FS - n | 1C 2D n | Turn underline mode on/off for Kanji characters. |
FS . | 1C 2E | Cancel Kanji character mode. |
FS 2 c1 c2 d1..dk | 1C 32 c1 c2 d1..dk | Define user-defined Kanji characters. |
FS ? c1 c2 | 1C 3F c1 c2 | Cancel user-defined Kanji characters. |
FS C n | 1C 43 n | Select Kanji character code system. |
FS S n1 n2 | 1C 53 n1 n2 | Set Kanji character spacing. |
FS W n | 1C 57 n | Set quadruple-size mode on/off for Kanji characters. |
GS ( A pL pH n m | 1D 28 41 02 00 n m | Execute test print where n is the paper used (0 basic sheet, 1 roll paper) and m depends on the printer. |