• esc-pos
  • starprnt
  • receiptline
  • star-line
  • printers

ESC/POS, StarPRNT and ReceiptLine: printer languages and receipt formats

What a receipt printer receives: bytes and command codes. ESC/POS and StarPRNT, code pages, QR codes and cutters, and ReceiptLine as an open text format.

A receipt printer usually does not receive a picture or a web page. It receives a stream of bytes: the characters to print, mixed with short command sequences that switch bold on, centre a line, print a QR code or cut the paper. The set of those commands is the printer’s language, such as ESC/POS, which Epson introduced and many printers speak, and StarPRNT, which Star uses, and ReceiptLine is an open text format one level above them that describes a receipt and leaves the bytes to software.

What the printer receives

The characters to print are only part of the stream: styles, positions and the cut are commands too, and an image adds much more, a QR code too when it is sent as a picture. ReceiptLine 4.0.4 writes the receipt shown further down, at 48 characters a line in code page 852, as about 1.9 KB of ESC/POS, most of it the QR code, which ReceiptLine sends as a picture, and the text is about 3% of that. A command usually starts with a control byte, 1B (ESC) or 1D (GS), followed by a code and parameters; some start with 1C (FS), and a few are a single byte, such as the line feed 0A. Here is the start of one receipt in both languages. The StarPRNT commands are from Star’s StarPRNT command specification, and the ESC/POS commands are the ones the open-source ReceiptLine 4.0.4 writes for the same functions. ReceiptLine’s own bytes are not identical to these listings: it centres text with print-position commands instead of the centring command, and it writes the Star cut as 1B 64 33, which Star’s specification lists as the same cut as 1B 64 03. The emphasis parameter in the ESC/POS listing is the ASCII digit that ReceiptLine writes.

Choose an option
1B 40                                     ESC @       initialise
1B 74 12                                  ESC t 18    code page 852
1B 61 01                                  ESC a 1     centre
1B 45 31                                  ESC E 1     emphasis on
48 61 72 62 6F 75 72 20 43 61 66 65 0A    Harbour Cafe, line feed
1B 45 30                                  ESC E 0     emphasis off
1B 61 00                                  ESC a 0     left
...
1D 56 42 00                               GS V 66 0   cut
1B 40                                     ESC @       initialise
1B 1D 74 05                               ESC GS t 5  code page 852
1B 1D 61 01                               ESC GS a 1  centre
1B 45                                     ESC E       emphasis on
48 61 72 62 6F 75 72 20 43 61 66 65 0A    Harbour Cafe, line feed
1B 46                                     ESC F       emphasis off
1B 1D 61 00                               ESC GS a 0  left
...
1B 64 03                                  ESC d 3     feed and partial cut

Compare the tabs. Initialising is the same in both. Centring is 1B 61 n in one and 1B 1D 61 n in the other. 1B 45 is a complete “emphasis on” in StarPRNT, but in ESC/POS it needs a third byte that says on or off. The cut and the code page numbers differ too. A stream written for one language can print wrong, or not at all, on the other.

Commands are stateful. Emphasis stays on until another command turns it off, and the chosen code page stays until another page is chosen or the printer is initialised, reset or switched off. That is why each listing ends a style it began, and why one missing reset can leak bold text into whatever the printer prints next, if that job does not start by initialising the printer.

ESC/POS: one command set, many dialects

Epson introduced ESC/POS, and its technical reference guide for one printer family calls it a proprietary POS printer command system. Other makers implement the same codes: Wikipedia notes that many current thermal receipt printers still use it, and a software agency that built a cloud POS calls it the industry standard. In detail it is a family of dialects. The PyESCPOS project warns that makers modify it, so a sequence that works on one printer may not work on another. Odoo’s documentation lists a few Epson printers that lack the GS v 0 image command that most Epson printers support.

Star’s languages and emulations

Star’s CloudPRNT guide (CloudPRNT is Star’s protocol for printing from a server in the cloud) lists formats such as StarPRNT and a “core” variant of it, two line modes (thermal and dot matrix), a raster format and PNG; which of them a printer takes depends on the device. Star Line Mode is a separate Star command set that some Star printers speak instead of StarPRNT, and Tillcast does not support it. A Star printer can also speak another language. Star’s help centre describes desktop printers that switch between their line mode and ESC/POS mode with DIP switches, and kiosk printers that switch between StarPRNT and ESC/POS. Which one is right depends on the software that prints, and Star advises asking the POS provider.

What goes wrong in practice

  • Code pages. A printer holds dozens of code pages, and a command picks one. Łódź in code page 852 is 9D A2 64 AB. A printer left in code page 437 prints ¥ód½ for those bytes, and the UTF-8 bytes of the word (C5 81 C3 B3 64 C5 BA) would print as ┼ü├│d┼║, six wrong symbols around a correct d. Which code pages a printer offers differs: Star’s specification gives different ranges of valid numbers for its code page command, and Epson’s technical reference guide for one printer family says that the default code page of its printer is selectable from 43 pages, a user-defined page included. Some printers also have multi-byte or UTF-8 modes. Star’s guide describes a header where a printer lists its code page support (utf8, std or dbcs); one Star printer in a test reported only std yet printed correctly in its UTF-8 mode, so treat it as a hint.
  • QR codes. A printer’s own QR code commands are a short conversation, not one command: choose the model, the module size and the error-correction level, store the data, print. StarPRNT has a command for each step, and ESC/POS has its own sequence of GS ( k commands. In ReceiptLine text it is one line.
  • Paper width. A line holds from about 32 to 48 characters in the standard font on 58 and 80 mm paper, depending on the paper, the font and the printer. Star’s CloudPRNT guide lists headers in which a printer reports its paper width, print width and dot resolution when it asks for a job.
  • Cutters. Star’s cut command has a full and a partial form, and not every cutter does both: Star’s specification says that a model with only one kind of cut makes that cut whichever is asked for. Star’s CloudPRNT lets a text or image job ask for a full, partial or no cut.
  • Status. StarPRNT has commands for status, such as ESC RS a, which sets whether the printer sends its status by itself each time it changes. Star’s CloudPRNT reports codes such as 200 for ready, 410 for paper out and 420 for cover open. A language can have the commands, but what reaches you depends on the connection.

Other ways to describe a receipt

ReceiptLine is “Markdown for receipts”, in the words of its README: plain text that describes a receipt and does not depend on the paper width. It is Apache-2.0 licensed and maintained as an independent, vendor-neutral project by the OpenReceipt Project. The same text becomes printer commands for the Epson, Seiko Instruments, Star, Citizen and Fujitsu printers its README lists, or an image, or plain text. A | separates columns, the spaces around it set the alignment, a " switches emphasis on, a line of dashes is a rule, = is a cut, and a property in braces holds a QR code. Its README says that communication with the printer and status handling are out of scope. Its Designer edits and previews a receipt in the browser; run on your own machine, it can also show the hex dump a printer would get and send a test print.

Views of the receipt
Paper width
Harbour Cafe
Order 1042
QR Code: https://example.com/orders/1042
Harbour Cafe
Order 1042
QR Code: https://example.com/orders/1042
"Harbour Cafe
Order 1042
{width:*,9}
|Tea | 2.10|
|Scone | 3.20|
-
|"Total | "5.30|
| {option:qrcode,4,l;code:https://example.com/orders/1042} |
=

A receipt headed Harbour Cafe in bold, then Order 1042, two lines Tea 2.10 and Scone 3.20, a rule, a bold total of 5.30 and a QR code.

                  Harbour Cafe
                   Order 1042
Tea                                         2.10
Scone                                       3.20
------------------------------------------------
Total                                       5.30
The receipt of the byte listing, as ReceiptLine text, drawn on 80 mm and 58 mm paper.

Star has a markup of its own, Star Document Markup, which works with its .NET API or its CPUtil tool. A different approach skips the text commands: render a page from HTML or a PDF to an image and send the image, as a raster command or, where the printer takes it, as PNG. Star’s CloudPRNT accepts PNG, and some devices also JPEG. You get no code page problems, but the printer’s own fonts and text commands are not used, and an image is bigger than text, which matters because Star limits a downloaded job to 512.0 KB on most printers.

Why an API for many printers has to deal with these differences

A POS that says “print this receipt” leaves the items above to someone: a driver, an SDK or an API. Printers differ in language, code page, line width, cut and QR sequence, and models differ in detail, so a print API has to be tested on the models it claims to support. That work is what a print API is for. It is also why such an API says which printers it has run on and which it has not.

How Tillcast uses it

Tillcast accepts a document in two formats, a list of blocks or ReceiptLine text. When a job is accepted, the document is turned into the commands of the printer it is sent to: StarPRNT for a Star printer on CloudPRNT and ESC/POS for an Epson printer with Server Direct Print. Star Line Mode, described above, is not supported. The docs explain documents, previewing a receipt and supported printers.

Sources

Read in October 2026.