Technician helping with ESC/POS browser printing and JS receipt template

Joe B.

Reviewed for technical accuracy

Specialities: POS & thermal printers (Epson TM/Star TSP/BIXOLON), WebUSB/Web Serial/WebHID, IPP/RAW, Kiosk setups

Print to thermal printers from the browser — driverless ESC/POS with JavaScript (WebUSB / Web Serial / WebHID)

Technician avatar Technician
Hey! Let’s set up ESC/POS web printing without drivers. We’ll use modern browser APIs so your site prints receipts directly to a thermal printer — no spooler, no vendor driver. Tell me your model (e.g., Epson TM‑T20/TM‑T88, Star TSP100/143, BIXOLON SRP), interface (USB, Serial, Bluetooth, or Ethernet), target browsers (Chrome/Edge), and whether you need cut paper, open cash drawer, QR/barcodes, or logo.
Customer
We have Epson TM‑T20II over USB. Goal: driverless printing from browser using JavaScript, a simple JS/CSS receipt template, and a test page button. Needs logo, QR, and automatic cut + cash drawer.
Technician avatar Technician
Perfect. For USB thermal printers we have three viable paths:
• WebUSB — talk raw to the device (best for Epson/Star with known interfaces). Requires HTTPS, user gesture, and vendor/product IDs.
• Web Serial — works if the printer presents a serial profile (CDC/ACM/USB‑to‑Serial). Also needs HTTPS and permission prompts.
• WebHID — for devices exposing HID. Good fallback on some Star models.
We’ll build a small JS layer that converts your receipt into ESC/POS commands and streams them over the chosen API. Your CSS/HTML template renders on screen; the Print button uses a driverless printing path for the device.
Customer
What about Chrome/Edge support and permissions? We run on a secure domain with HTTPS and want persistent access.
Technician avatar Technician
Browser requirements: All three APIs require HTTPS and a user gesture (click) to connect. On first run the user selects the device; after that, sites can re‑request access by device serial/Vid/Pid. For kiosks you can pin the device with WebUSB allow‑lists (Chrome policy) or use a local helper app only if corporate policy demands silent printing (we’ll try to stay 100% in‑browser).
Customer
How do we format receipts? We want 80mm and 58mm variants with bold, alignments, and item tables.
Technician avatar Technician
We’ll keep a clean JS/CSS receipt template in the page and translate it to ESC/POS:
• Text: align left/center/right, bold/double‑width, codepages/UTF‑8 where supported.
• Tables: pad to character width (32–42 chars for 58/80mm).
• Logo & images: render HTML to a canvas, then dither to 1‑bit and send using GS ( L image format (or classic ESC * for compatibility).
• Barcodes/QR: use native printer commands when available; else send a raster image.
We’ll include a test page that exercises bold, alignment, barcode/QR, and totals.
Customer
We need open cash drawer and auto‑cut after printing. Also, can we print in different languages?
Technician avatar Technician
Yes. We’ll append standard ESC/POS sequences: GS V for partial/full paper cut, and ESC p to open the cash drawer (kick pulse) on DK port. For languages: prefer UTF‑8 models, otherwise set the proper codepage (e.g., CP437/858/852/866) before writing text. We’ll add examples in the driverless printing test page.
Customer
Any gotchas with CORS/HTTPS, and can this work offline in a PWA?
Technician avatar Technician
Great question. WebUSB/Web Serial/WebHID require HTTPS (or http://localhost) and a user gesture. Assets for logos/fonts must be accessible to the page origin to avoid CORS failures. For PWA use a Service Worker to cache the JS/CSS template and logo; the APIs work offline after permission, so your kiosk can print in airplane‑mode as long as the device is connected.
Customer
Some sites mention raw TCP (9100) or IPP 631. Can we do network printing from the browser too?
Technician avatar Technician
Browsers don’t expose raw sockets for TCP 9100 or IPP 631 directly. For Ethernet printers you can either: (a) still use WebUSB/Web Serial via a USB cable; (b) send print jobs through a tiny local bridge (Node/Go) if you truly need raw TCP; or (c) host an HTTP endpoint on the LAN that accepts ESC/POS payloads. We’ll keep our core flow 100% driverless in the browser where possible.
Customer
Can we ship a ready test page to validate each station — logo, barcodes, QR, totals, cut and drawer?
Technician avatar Technician
Absolutely. We provide a driverless printing test page with a Connect button and a Print test receipt button. It exercises: header/logo, item lines with tax/discount, barcode/QR, subtotal/total, cut paper and open cash drawer. The same JS module supports 80mm and 58mm widths and includes fallbacks for older firmware.
Customer
We also use Star TSP143 at a different shop. Will the same JavaScript work?
Technician avatar Technician
Yes — we keep a small capabilities map for Epson TM, Star TSP, and BIXOLON. Most accept standard ESC/POS; where models use vendor extensions (e.g., Star line mode), we switch to compatible sequences. Our module detects the device at connect time and chooses the right cut/barcode/QR commands.
Customer
Great — once set up, can staff print from a normal web app checkout flow with one click?
Technician avatar Technician
Summary: With ESC/POS web printing via WebUSB/Web Serial/WebHID, your site can print receipts without drivers. Use our JS/CSS receipt template and test page, then integrate a one‑click button in checkout. We’ll handle QR/barcodes, cut, and cash drawer, with fallbacks for different thermal printers. Need hands‑on help? Open the chat.

Quick answer: the accepted fix

Accepted approach for ESC/POS web printing without drivers: connect the thermal printer with WebUSB, Web Serial, or WebHID over HTTPS; render the receipt with JS/CSS; convert to ESC/POS commands (text, images, barcodes/QR); then cut paper and open cash drawer. Validate with the included driverless test page.


Browser APIs for thermal printers — WebUSB vs Web Serial vs WebHID

WebUSB gives the most control for Epson TM and Star TSP USB models (vendor/product IDs, bulk endpoints). Web Serial is ideal when the device exposes a serial profile (CDC/ACM or USB‑to‑Serial adapters). WebHID can reach HID‑mode printers. All require HTTPS, user consent, and a clear on‑screen Connect button for secure, driverless printing.

How to verify ESC/POS from a web app

Use our JS test page: connect the device, then print a sample receipt showing bold/centered title, line items with totals, barcode/QR, and logo. The page reports success/failure bytes and suggests alternatives (image raster vs native QR) if firmware lacks a feature.

Receipt quality & reliability tips

Most issues come from wrong codepage, missing HTTPS, or mixing vendor command sets.

Quick path: confirm HTTPS and device permissions → pick the right API (WebUSB/Web Serial/WebHID) → set codepage/UTF‑8 for language → for images, dither to 1‑bit and use GS ( L → test cut and drawer with safe pulse widths → provide a print test page to each station.

Disclaimer: This information is AI-generated and intended for general guidance only. For advice specific to your environment, please consult a verified expert on Whizz-Tech before making decisions.


Getting Started Is Easy

Ask for help, 24/7

Members enjoy round-the-clock access to 12,000+ verified Experts, including tech support, mechanics, vets, and more.

Expert will respond in minutes

We match you with an Expert who specializes in your situation. Talk, text, or chat — whichever you prefer.

Save time & money

No scheduling hassles or expensive consults. Membership can save you significant time and money each month.

FAQ

Which browsers support ESC/POS printing via JavaScript?

Chrome, Edge, and most Chromium‑based browsers expose WebUSB, Web Serial, and WebHID. All require HTTPS and user consent to connect to the thermal printer.

Can I print from a web page without installing any drivers?

Yes. This article shows driverless ESC/POS printing using WebUSB/Web Serial/WebHID. Your app sends ESC/POS commands directly to the printer from the browser.

How do I trigger cut and open the cash drawer?

Use GS V for partial/full cut and ESC p to trigger the cash drawer (DK port). Our test page includes safe defaults for pulse width and timing.

Can I print images, barcodes and QR codes?

Yes. Send images as GS ( L raster data; use printer‑native QR/barcode commands when supported, or fall back to rasterized codes.

Will this work with Epson TM and Star TSP printers?

Yes. We include compatibility notes for Epson TM‑T20/TM‑T88 and Star TSP100/143. The JS picks the right command set automatically.

Common driverless printing issues and quick fixes
SymptomLikely causeQuick fix
Browser can’t see the printer No HTTPS or permission not granted Serve over HTTPS and click Connect; whitelist device by VID/PID if needed
Garbled characters Wrong codepage / no UTF‑8 Switch to UTF‑8 model or set correct codepage before writing text
Logo/QR too light Bad dithering or incorrect raster mode Convert to 1‑bit, use GS ( L image format, increase darkness
Drawer doesn’t open Pulse timing mismatch Use ESC p with supported pin and width; test on the test page

Step‑by‑step (WebUSB / Web Serial / WebHID)

  1. Serve your app over HTTPS (or localhost for dev). Add a visible Connect button.
  2. On click, request the device via WebUSB (preferred), or fallback to Web Serial/WebHID based on the model.
  3. Render the receipt in a JS/CSS template, then convert to ESC/POS (text → bytes; images → raster).
  4. Send QR/barcodes, totals, then issue GS V (cut) and ESC p (drawer) as needed.
  5. Validate using the built‑in driverless printing test page; adjust darkness and codepage.

Step‑by‑step (Kiosk hardening)

  1. Pin the site as a PWA with a Service Worker and offline cache for assets and templates.
  2. Lock down Chrome policies (optional): WebUSB allow‑lists for the printer VID/PID to streamline pairing.
  3. Create a fallback network queue (IPP/RAW) only if corporate policy forbids device APIs; otherwise stay driverless.

Sources

Matt Verified Icon
Matt ● replies in < 1 min
Technician Expert
⭐⭐⭐⭐⭐ Trusted by 27,000+ customers
Avatar
Alex · Expert's Assistant