ESC/POS Receipt Generator Online
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.
Result
Press “Run” to see the result.
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.
Use this in your code
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!"}}'const res = await fetch('https://apibox.io.vn/v1/escpos-receipt', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"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!"
}
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/escpos-receipt",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"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!"}},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/escpos-receipt');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"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 = curl_exec($ch);
print_r(json_decode($response, true));API documentation → Get a free API key
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.