ESC/POS Receipt Generator (Vietnamese-safe) API

Turn a receipt (items, totals, QR, barcode) into ESC/POS bytes for 58 / 80 mm thermal printers, with Vietnamese printed as an image and a PNG preview.

POSThttps://apibox.io.vn/v1/escpos-receipt
Images & Codes▶ Try it online

Describe the receipt as blocks (text with align / bold / size / underline / invert, row with left and right text, divider, feed, qr, barcode (Code 128, EAN-13, Code 39), image (PNG / JPEG, dithered)) or as a simple receipt object (store, header, title, info, items with name / qty / price, discount, vat, total, paid, qr, footer) and get the ESC/POS byte stream (base64) plus a PNG preview of exactly what will print.

Thermal printers sold in Vietnam often have no Vietnamese code page, so mode=raster (default) draws all text with the Be Vietnam Pro font and sends the receipt as a GS v 0 bit image: diacritics print correctly on any ESC/POS printer. mode=tcvn3 sends native text in the TCVN-3 code page (ESC t 30, Epson-compatible printers; faster, but toned capitals are missing), mode=ascii removes diacritics. In the text modes QR codes and barcodes use the printer’s own commands. cut (default on) adds a partial cut, open_drawer=true kicks the cash drawer.

APIBox cannot reach a printer on your network: send the bytes yourself through WebUSB, Web Bluetooth, a TCP socket to port 9100, or the RawBT app on Android. format=bin returns the raw bytes, format=png the preview only.

Markdown · OpenAPI · Postman · llms.txt

Parameters

NameInTypeRequiredDefault
receiptbodyobjectnoSimple receipt: store, header, title, info, items [{name, qty, price}], discount, vat, total, paid, qr, qr_caption, barcode, footer, currency.
blocksbodyarraynoLayout blocks: text, row, divider, feed, qr, barcode, image (max 500).
paperbodystringno8058 or 80 (mm).
modebodystringnorasterraster (text as image, any printer), tcvn3 (code page 30) or ascii (no diacritics).
cutbodybooleannotruePartial cut at the end.
open_drawerbodybooleannofalseKick the cash drawer.
formatbodystringnojsonjson (base64 + preview), bin (raw bytes) or png (preview).

Example

curl -X POST "https://apibox.io.vn/v1/escpos-receipt" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"paper":"58","receipt":{"store":"Quán Cà Phê","items":[{"name":"Cà phê sữa đá","qty":2,"price":29000}],"paid":100000,"footer":"Cảm ơn quý khách!"}}'

Response

{
  "paper_mm": 58,
  "mode": "raster",
  "width_dots": 384,
  "height_dots": 318,
  "length_mm": 39.8,
  "bytes": 15289,
  "escpos_base64": "G0AddjAAMAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA…",
  "preview_png": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYAAAAE+CAAAAA…",
  "warnings": [],
  "notes": "Raster mode (GS v 0) prints Vietnamese on any ESC/POS printer."
}

Use cases

  • Print receipts with correct Vietnamese from a web POS through WebUSB
  • Generate kitchen / bar tickets from Google Sheets or AppSheet orders
  • Add a VietQR payment code to receipts printed by a Flutter app
  • Preview receipt layouts before sending them to a printer

FAQ

Why does Vietnamese print as question marks on my printer?

The printer has no Vietnamese code page. Use mode=raster (the default): the text is printed as an image, which every ESC/POS printer supports.

Which printers are supported?

Any ESC/POS-compatible 58 mm (384 dots) or 80 mm (576 dots) printer, e.g. Epson TM, Xprinter, Gprinter, Rongta, Sunmi.

Can APIBox print directly?

No, a cloud API cannot reach your LAN or USB. Send the returned bytes to the printer from your app, browser or a print relay.

Related APIs

Start with 1,000 free requests every month. Get free API key →