{"id":40671765,"url":"https://github.com/receiptline/receiptjs","last_synced_at":"2026-01-21T09:35:35.405Z","repository":{"id":228714047,"uuid":"773825854","full_name":"receiptline/receiptjs","owner":"receiptline","description":"Print libraries for receipt printers, simple and easy with markdown, printer status support.","archived":false,"fork":false,"pushed_at":"2025-10-29T13:55:38.000Z","size":229,"stargazers_count":47,"open_issues_count":2,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-29T15:38:05.528Z","etag":null,"topics":["barcode","epson","escpos","printer","qrcode","receipt","star","starprnt","webserial"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/receiptline.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-18T13:20:06.000Z","updated_at":"2025-10-29T13:55:35.000Z","dependencies_parsed_at":"2024-03-20T05:28:34.530Z","dependency_job_id":"191570fe-ae3f-4ab9-b9db-be796ca78879","html_url":"https://github.com/receiptline/receiptjs","commit_stats":null,"previous_names":["receiptline/receiptjs"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/receiptline/receiptjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/receiptline%2Freceiptjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/receiptline%2Freceiptjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/receiptline%2Freceiptjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/receiptline%2Freceiptjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/receiptline","download_url":"https://codeload.github.com/receiptline/receiptjs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/receiptline%2Freceiptjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28631228,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["barcode","epson","escpos","printer","qrcode","receipt","star","starprnt","webserial"],"created_at":"2026-01-21T09:35:34.571Z","updated_at":"2026-01-21T09:35:35.395Z","avatar_url":"https://github.com/receiptline.png","language":"JavaScript","readme":"# Receipt.js\r\n\r\nJavaScript printing libraries for receipt printers, simple and easy with receipt markdown, printer status support.  \r\n\r\n```javascript\r\nconst markdown = `^^^RECEIPT\r\n\r\n03/18/2024, 12:34:56 PM\r\nAsparagus | 1| 1.00\r\nBroccoli  | 2| 2.00\r\nCarrot    | 3| 3.00\r\n---\r\n^TOTAL | ^6.00`;\r\n\r\nconst receipt = Receipt.from(markdown, '-c 42 -l en');\r\nconst png = await receipt.toPNG();\r\n```\r\n\r\n![example](resource/example.png)  \r\n\r\n\r\n# Features\r\n\r\nReceipt.js is simple printing libraries for receipt printers that prints with easy markdown data for receipts and returns printer status. Even without a printer, it can output images.  \r\n\r\nA development tool is provided to edit, preview, and print the receipt markdown.  \r\nhttps://receiptline.github.io/receiptjs-designer/  \r\n\r\nThe details of the receipt markdown are explained at  \r\nhttps://github.com/receiptline/receiptline  \r\n\r\n# Convert to image or plain text\r\n\r\nThe following files are required to use the Receipt API.  \r\n\r\n- receipt.js\r\n\r\n```html\r\n\u003cscript type=\"text/javascript\" src=\"receipt.js\"\u003e\u003c/script\u003e\r\n```\r\n\r\n```javascript\r\nconst markdown = `^^^RECEIPT\r\n\r\n03/18/2024, 12:34:56 PM\r\nAsparagus | 1| 1.00\r\nBroccoli  | 2| 2.00\r\nCarrot    | 3| 3.00\r\n---\r\n^TOTAL | ^6.00`;\r\n\r\nconst receipt = Receipt.from(markdown, '-c 42 -l en');\r\nconst png = await receipt.toPNG();\r\n```\r\n\r\n## Receipt.from(markdown[, options])\r\n\r\nThe Receipt.from() static method creates a new Receipt instance.  \r\n\r\n### Parameters  \r\n\r\n- `markdown` \u0026lt;string\u0026gt;\r\n  - receipt markdown text\r\n- `options` \u0026lt;string\u0026gt;\r\n  - `-c \u003cchars\u003e`: characters per line\r\n    - range: `24`-`96`\r\n    - default: `48`\r\n  - `-l \u003clanguage\u003e`: language of receipt markdown text\r\n    - `en`, `fr`, `de`, `es`, `po`, `it`, `ru`, ...: Multilingual (cp437, 852, 858, 866, 1252 characters)\r\n    - `ja`: Japanese (shiftjis characters)\r\n    - `ko`: Korean (ksc5601 characters)\r\n    - `zh-hans`: Simplified Chinese (gb18030 characters)\r\n    - `zh-hant`: Traditional Chinese (big5 characters)\r\n    - `th`: Thai\r\n    - default: system locale\r\n  - `-s`: paper saving (reduce line spacing)\r\n\r\n### Return value\r\n\r\n  - A new Receipt instance.\r\n\r\n## receipt.toPNG()\r\n\r\nThe toPNG() instance method converts to PNG.  \r\nhttps://receiptline.github.io/receiptjs/test/topng.html  \r\n\r\n### Parameters\r\n\r\n- None.\r\n\r\n### Return value\r\n\r\n- A Promise that fulfills with a string once the PNG in data URL format is ready to be used.\r\n\r\n## receipt.toSVG()\r\n\r\nThe toSVG() instance method converts to SVG.  \r\nhttps://receiptline.github.io/receiptjs/test/tosvg.html  \r\n\r\n### Parameters\r\n\r\n- None.\r\n\r\n### Return value\r\n\r\n- A Promise that fulfills with a string once the SVG is ready to be used.\r\n\r\n## receipt.toText()\r\n\r\nThe toText() instance method converts to plain text.  \r\nhttps://receiptline.github.io/receiptjs/test/totext.html  \r\n\r\n### Parameters\r\n\r\n- None.\r\n\r\n### Return value\r\n\r\n- A Promise that fulfills with a string once the plain text is ready to be used.\r\n\r\n## receipt.toString()\r\n\r\nThe toString() instance method returns a string representing the receipt markdown text.  \r\n\r\n### Parameters\r\n\r\n- None.\r\n\r\n### Return value\r\n\r\n- A string representing the receipt markdown text.\r\n\r\n\r\n# Convert to printer commands\r\n\r\nThe following files are required to use the Receipt Printer API.  \r\n\r\n- receipt.js\r\n- receipt-printer.js\r\n\r\n```html\r\n\u003cscript type=\"text/javascript\" src=\"receipt.js\"\u003e\u003c/script\u003e\r\n\u003cscript type=\"text/javascript\" src=\"receipt-printer.js\"\u003e\u003c/script\u003e\r\n```\r\n\r\n```javascript\r\nconst markdown = `^^^RECEIPT\r\n\r\n03/18/2024, 12:34:56 PM\r\nAsparagus | 1| 1.00\r\nBroccoli  | 2| 2.00\r\nCarrot    | 3| 3.00\r\n---\r\n^TOTAL | ^6.00`;\r\n\r\nconst receipt = Receipt.from(markdown, '-p generic -c 42');\r\nconst command = await receipt.toCommand();\r\n```\r\n\r\n## Receipt.from(markdown[, options])\r\n\r\nThe Receipt.from() static method creates a new Receipt instance.  \r\n\r\n### Parameters\r\n\r\n- `markdown` \u0026lt;string\u0026gt;\r\n  - receipt markdown text\r\n- `options` \u0026lt;string\u0026gt;\r\n  - `-p \u003cprinter\u003e`: printer control language\r\n    - `escpos`: ESC/POS (Epson)\r\n    - `epson`: ESC/POS (Epson)\r\n    - `sii`: ESC/POS (Seiko Instruments)\r\n    - `citizen`: ESC/POS (Citizen)\r\n    - `fit`: ESC/POS (Fujitsu)\r\n    - `impact`: ESC/POS (TM-U220)\r\n    - `impactb`: ESC/POS (TM-U220 Font B)\r\n    - `generic`: ESC/POS (Generic) _Experimental_\r\n    - `star`: StarPRNT\r\n    - `starline`: Star Line Mode\r\n    - `emustarline`: Command Emulator Star Line Mode\r\n    - `stargraphic`: Star Graphic Mode\r\n    - `starimpact`: Star Mode on dot impact printers _Experimental_\r\n    - `starimpact2`: Star Mode on dot impact printers (Font 5x9 2P-1) _Experimental_\r\n    - `starimpact3`: Star Mode on dot impact printers (Font 5x9 3P-1) _Experimental_\r\n  - `-c \u003cchars\u003e`: characters per line\r\n    - range: `24`-`96`\r\n    - default: `48`\r\n  - `-l \u003clanguage\u003e`: language of receipt markdown text\r\n    - `en`, `fr`, `de`, `es`, `po`, `it`, `ru`, ...: Multilingual (cp437, 852, 858, 866, 1252 characters)\r\n    - `ja`: Japanese (shiftjis characters)\r\n    - `ko`: Korean (ksc5601 characters)\r\n    - `zh-hans`: Simplified Chinese (gb18030 characters)\r\n    - `zh-hant`: Traditional Chinese (big5 characters)\r\n    - `th`: Thai\r\n    - default: system locale\r\n  - `-s`: paper saving (reduce line spacing)\r\n  - `-m [\u003cleft\u003e][,\u003cright\u003e]`: print margin\r\n    - range (left): `0`-`24`\r\n    - range (right): `0`-`24`\r\n    - default: `0,0`\r\n  - `-u`: upside down\r\n  - `-i`: print as image\r\n  - `-n`: no paper cut\r\n  - `-b \u003cthreshold\u003e`: image thresholding\r\n    - range: `0`-`255`\r\n    - default: error diffusion\r\n  - `-g \u003cgamma\u003e`: image gamma correction\r\n    - range: `0.1`-`10.0`\r\n    - default: `1.0`\r\n  - `-v`: landscape orientation\r\n    - device font support: `escpos`, `epson`, `sii`, `citizen`, `star`\r\n  - `-r \u003cdpi\u003e`: print resolution for ESC/POS, landscape, and device font\r\n    - values: `180`, `203`\r\n    - default: `203`\r\n\r\n### Return value\r\n\r\n  - A new Receipt instance.\r\n\r\n## receipt.toCommand()\r\n\r\nThe toCommand() instance method converts to printer commands.  \r\nhttps://receiptline.github.io/receiptjs/test/tocommand.html  \r\n\r\n### Parameters\r\n\r\n- None.\r\n\r\n### Return value\r\n\r\n- A Promise that fulfills with a string once the printer commands is ready to be used.\r\n\r\n\r\n# Print with the Web Serial API\r\n\r\nThe following files are required to use the Receipt Serial API.  \r\n\r\n- receipt.js\r\n- receipt-printer.js\r\n- receipt-serial.js\r\n\r\n```html\r\n\u003cscript type=\"text/javascript\" src=\"receipt.js\"\u003e\u003c/script\u003e\r\n\u003cscript type=\"text/javascript\" src=\"receipt-printer.js\"\u003e\u003c/script\u003e\r\n\u003cscript type=\"text/javascript\" src=\"receipt-serial.js\"\u003e\u003c/script\u003e\r\n```\r\n\r\n```javascript\r\nconst markdown = `^^^RECEIPT\r\n\r\n03/18/2024, 12:34:56 PM\r\nAsparagus | 1| 1.00\r\nBroccoli  | 2| 2.00\r\nCarrot    | 3| 3.00\r\n---\r\n^TOTAL | ^6.00`;\r\n\r\nconst conn = ReceiptSerial.connect({ baudRate: 19200 });\r\nconn.on('status', status =\u003e {\r\n    console.log(status);\r\n});\r\nconn.on('ready', async () =\u003e {\r\n    const result = await conn.print(markdown, '-c 42');\r\n});\r\n```\r\n\r\n## ReceiptSerial.connect([options])\r\n\r\nThe ReceiptSerial.connect() static method creates a new connection using the Web Serial API.  \r\n\r\n### Parameters\r\n\r\n- `options` \u0026lt;object\u0026gt;\r\n  - `baudRate`: baud rate to establish serial communication\r\n    - default: `115200`\r\n  - other values\r\n    - parity: `none`\r\n    - data bits: `8`\r\n    - stop bits: `1`\r\n    - flow control: `hardware`\r\n\r\nThese options are for real serial ports.  \r\n\r\n### Return value\r\n\r\n  - A new ReceiptSerial instance.\r\n\r\n## receiptSerial.status\r\n\r\nThe receiptSerial.status instance property is a string representing the printer status.  \r\n\r\n### Value\r\n\r\n- A string representing the printer status.\r\n  - `online`: printer is online\r\n  - `print`: printer is printing\r\n  - `coveropen`: printer cover is open\r\n  - `paperempty`: no receipt paper\r\n  - `error`: printer error (except cover open and paper empty)\r\n  - `offline`: printer is off or offline\r\n  - `disconnect`: printer is not connected\r\n\r\n## receiptSerial.print(markdown[, options])\r\n\r\nThe print() instance method prints a receipt markdown text.  \r\nhttps://receiptline.github.io/receiptjs/test/print.html  \r\n\r\n### Parameters\r\n\r\n- `markdown` \u0026lt;string\u0026gt;\r\n  - receipt markdown text\r\n- `options` \u0026lt;string\u0026gt;\r\n  - `-c \u003cchars\u003e`: characters per line\r\n    - range: `24`-`96`\r\n    - default: `48`\r\n  - `-l \u003clanguage\u003e`: language of receipt markdown text\r\n    - `en`, `fr`, `de`, `es`, `po`, `it`, `ru`, ...: Multilingual (cp437, 852, 858, 866, 1252 characters)\r\n    - `ja`: Japanese (shiftjis characters)\r\n    - `ko`: Korean (ksc5601 characters)\r\n    - `zh-hans`: Simplified Chinese (gb18030 characters)\r\n    - `zh-hant`: Traditional Chinese (big5 characters)\r\n    - `th`: Thai\r\n    - default: system locale\r\n  - `-s`: paper saving (reduce line spacing)\r\n  - `-m [\u003cleft\u003e][,\u003cright\u003e]`: print margin\r\n    - range (left): `0`-`24`\r\n    - range (right): `0`-`24`\r\n    - default: `0,0`\r\n  - `-u`: upside down\r\n  - `-i`: print as image\r\n  - `-n`: no paper cut\r\n  - `-b \u003cthreshold\u003e`: image thresholding\r\n    - range: `0`-`255`\r\n    - default: error diffusion\r\n  - `-g \u003cgamma\u003e`: image gamma correction\r\n    - range: `0.1`-`10.0`\r\n    - default: `1.0`\r\n  - `-p \u003cprinter\u003e`: printer control language\r\n    - `escpos`: ESC/POS (Epson)\r\n    - `epson`: ESC/POS (Epson)\r\n    - `sii`: ESC/POS (Seiko Instruments)\r\n    - `citizen`: ESC/POS (Citizen)\r\n    - `fit`: ESC/POS (Fujitsu)\r\n    - `impact`: ESC/POS (TM-U220)\r\n    - `impactb`: ESC/POS (TM-U220 Font B)\r\n    - `generic`: ESC/POS (Generic) _Experimental_\r\n    - `star`: StarPRNT\r\n    - `starline`: Star Line Mode\r\n    - `emustarline`: Command Emulator Star Line Mode\r\n    - `stargraphic`: Star Graphic Mode\r\n    - `starimpact`: Star Mode on dot impact printers _Experimental_\r\n    - `starimpact2`: Star Mode on dot impact printers (Font 5x9 2P-1) _Experimental_\r\n    - `starimpact3`: Star Mode on dot impact printers (Font 5x9 3P-1) _Experimental_\r\n    - default: auto detection (`epson`, `sii`, `citizen`, `fit`, `impactb`, `generic`, `star`)\r\n  - `-v`: landscape orientation\r\n    - device font support: `escpos`, `epson`, `sii`, `citizen`, `star`\r\n  - `-r \u003cdpi\u003e`: print resolution for ESC/POS, landscape, and device font\r\n    - values: `180`, `203`\r\n    - default: `203`\r\n\r\n### Return value\r\n\r\n- A Promise that fulfills with a string once the print result is ready to be used.\r\n  - `success`: printing success\r\n  - `print`: printer is printing\r\n  - `coveropen`: printer cover is open\r\n  - `paperempty`: no receipt paper\r\n  - `error`: printer error (except cover open and paper empty)\r\n  - `offline`: printer is off or offline\r\n  - `disconnect`: printer is not connected\r\n\r\n## receiptSerial.drawer\r\n\r\nThe receiptSerial.drawer instance property is a string representing the cash drawer status.  \r\n\r\n### Value\r\n\r\n- A string representing the cash drawer status.\r\n  - `drawerclosed`: drawer is closed\r\n  - `draweropen`: drawer is open\r\n  - `offline`: printer is off or offline\r\n  - `disconnect`: printer is not connected\r\n\r\n## receiptSerial.invertDrawerState(invert)\r\n\r\nThe invertDrawerState() instance method inverts cash drawer state.  \r\n\r\n### Parameters\r\n\r\n- `invert` \u0026lt;boolean\u0026gt;\r\n  - if true, invert drawer state\r\n\r\n### Return value\r\n\r\n- None.\r\n\r\n## receiptSerial.close()\r\n\r\nThe close() instance method closes the connection.  \r\nThe current implementation also closes other open connections.  \r\n\r\n### Parameters\r\n\r\n- None.\r\n\r\n### Return value\r\n\r\n- None.\r\n\r\n## receiptSerial.on(name, listener)\r\n\r\nThe on() instance method adds the `listener` function to the listeners array for the event named `name`.  \r\n\r\n### Parameters\r\n\r\n- `name`\r\n  - event name\r\n    - `status`: printer status updated\r\n    - `ready`: ready to print\r\n    - `online`: printer is online\r\n    - `print`: printer is printing\r\n    - `coveropen`: printer cover is open\r\n    - `paperempty`: no receipt paper\r\n    - `error`: printer error (except cover open and paper empty)\r\n    - `offline`: printer is off or offline\r\n    - `disconnect`: printer is not connected\r\n    - `drawer`: drawer status updated\r\n    - `drawerclosed`: drawer is closed\r\n    - `draweropen`: drawer is open\r\n- `listener`\r\n  - the listener function\r\n\r\n### Return value\r\n\r\n- None.\r\n\r\n## receiptSerial.off(name, listener)\r\n\r\nThe off() instance method removes the `listener` function from the listeners array for the event named `name`.  \r\n\r\n### Parameters\r\n\r\n- `name`\r\n  - event name\r\n    - `status`: printer status updated\r\n    - `ready`: ready to print\r\n    - `online`: printer is online\r\n    - `print`: printer is printing\r\n    - `coveropen`: printer cover is open\r\n    - `paperempty`: no receipt paper\r\n    - `error`: printer error (except cover open and paper empty)\r\n    - `offline`: printer is off or offline\r\n    - `disconnect`: printer is not connected\r\n    - `drawer`: drawer status updated\r\n    - `drawerclosed`: drawer is closed\r\n    - `draweropen`: drawer is open\r\n- `listener`\r\n  - the listener function\r\n\r\n### Return value\r\n\r\n- None.\r\n\r\n\r\n# Web browsers\r\n\r\nThe print function is available on Chrome, Edge, and Opera that support the Web Serial API.  \r\n(Windows, Linux, macOS, ChromeOS, and **Android**)  \r\n\r\n\r\n# Receipt printers\r\n\r\n- Epson TM series\r\n- Seiko Instruments RP series\r\n- Star MC series\r\n- Citizen CT series\r\n- Fujitsu FP series\r\n\r\nConnect with the Web Serial API.  \r\n(Bluetooth, virtual serial port, and serial port)  \r\n\r\nEpson TM series (South Asia model) and Star MC series (StarPRNT model) can print with device font of Thai characters.  \r\n\r\n## Restrictions\r\n\r\nThe Web Serial API has no write timeout, so if hardware flow control is enabled, opening the printer cover during printing may cause the browser to stop responding. In this case, close the printer cover or press the paper feed button. Alternatively, change the printer's busy condition setting from \"Offline or receive buffer full\" to \"Receive buffer full\".  \r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freceiptline%2Freceiptjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freceiptline%2Freceiptjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freceiptline%2Freceiptjs/lists"}