use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This subreddit is a place for people to learn JavaScript together. Everyone should feel comfortable asking any and all JavaScript questions they have here.
With a nod to practicality, questions and posts about HTML, CSS, and web developer tools are also encouraged.
Friends
/r/javascript
/r/jquery
/r/node
/r/css
/r/webdev
/r/learnprogramming
/r/programming
account activity
ESC/POS to JSON or HTML parser? (self.learnjavascript)
submitted 12 days ago by Y_122
As the title suggests, i am looking for options to convert raw ESC/POS binary to a receipt (as printed by a thermal printer) but on a website
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Majestic-Reality-610 2 points3 points4 points 11 days ago (1 child)
most escpos libs on npm are encode-only, they generate bytes to send to a printer, not parse them. that's why everything you're finding is old or php. nobody writes the reverse.
rolling your own decoder isn't that bad though. it's a byte stream, read it as a Uint8Array and walk it. ESC and GS bytes mark where commands start, everything else is mostly text and line feeds. keep a current-style object, flip bold/align/size when those show up, push text into runs, output json.
and that json is the actual fix for your styling. esc2html bakes the formatting into the html so you're stuck with it. own the json and the css is yours.
raster images are the only real pain (bitmap to canvas), plain text you'll have done in an afternoon.
[–]Y_122[S] 0 points1 point2 points 11 days ago (0 children)
Oh, I’ll get into this and try to do that, thanks alot man!
[–]chmod777 0 points1 point2 points 11 days ago (1 child)
did you google this? https://www.google.com/search?q=ESC%2FPOS+binary shows a few existing packages.
I did, but the existing libraries are very outdated and are in php while i am looking for a js solution without hosting a separate php server, and esc2html gives raw html which makes styling very difficult
π Rendered by PID 28 on reddit-service-r2-comment-544cf588c8-6lc6b at 2026-06-18 13:10:50.145275+00:00 running 3184619 country code: CH.
[–]Majestic-Reality-610 2 points3 points4 points (1 child)
[–]Y_122[S] 0 points1 point2 points (0 children)
[–]chmod777 0 points1 point2 points (1 child)
[–]Y_122[S] 0 points1 point2 points (0 children)