Skip to content

mimito-6/receipt-engine

Repository files navigation

receipt-engine

🧾 receipt-engine

Receipts, but delightful. Turn structured receipt JSON into beautiful, shareable, printable receipts β€” designed right in your browser.


Live editor Β  Docs

Deploy License: MIT TypeScript Front-end only

English Β· 繁體中文 Β· ζ—₯本θͺž


The in-browser direct-manipulation editor

One receipt JSON in β†’ SVG, HTML, and PNG out. Same data, many surfaces β€” with a delightful direct-manipulation editor on top. Built for artist-alley booths, doujin events, craft markets, pop-up stores, and local-first POS tools (e.g. OpenBooth).

A receipt doesn't have to be ugly. For a creator at a booth, the receipt is a brand touchpoint β€” a tiny gift the customer keeps, scans, and shares. receipt-engine makes that easy while staying a neutral, embeddable library: pass it a receipt JSON, get back PNG / SVG / HTML β€” or hand a merchant the browser editor and let them design their own.

✨ Highlights

  • πŸ–ŒοΈ Direct-manipulation editor β€” tap text to restyle, drag stickers to scale/rotate, drag the card edges to resize, drag blocks to reorder. Runs entirely in the browser, on phones too.
  • πŸ“„ One schema, many outputs β€” SVG (canonical) Β· HTML Β· PNG, all deterministic.
  • 🎨 Themes β€” custom (colorful, change colors / fonts / stickers) and thermal (monospace, auto-grayscaled images), plus fully custom themes via mergeTheme.
  • πŸ—‚οΈ 8 ready-made starter templates β€” minimal Β· doujin booth Β· zine press Β· cafΓ© Β· craft market Β· pixel arcade Β· boutique Β· neon night β€” each with its own font, palette and personality. Pick one and tweak, or start blank.
  • πŸͺ™ Any currency β€” pick a code or just type your own symbol (NT$, Β₯, …); the editor renders it as-is.
  • ✢ Borderless vector stickers β€” a clean, solid-fill mark set (no emoji), scalable / rotatable on the canvas.
  • πŸ–¨οΈ Thermal printing β€” ESC/POS raster (GS v 0) over Web Bluetooth, straight from the browser.
  • πŸ“² Browser PNG & share β€” rasterize to PNG client-side (canvas) and share via Web Share β€” no server.
  • 🌏 i18n β€” the editor UI ships in δΈ­ζ–‡ / ζ—₯本θͺž / English.
  • πŸ”— QR codes, πŸ”’ smart totals, 🧱 custom blocks, 🧩 React component + CLI + typed core.
  • πŸ›‘οΈ Safe & deterministic β€” every user value is escaped; the receipt never leaves the browser for a server.

🎨 Themes

🎨 custom β€” colorful & brandable 🧾 thermal β€” receipt-printer look
custom theme thermal theme
Colors, fonts, stickers, logo, background image (scale / rotate), QR. Monospace, B&W, torn perforated edges β€” what a real till prints.

πŸš€ Try it

▢️ Open the live editor β€” no install, no login, works on your phone. Edit the sample receipt right on the canvas, then download PNG / SVG / HTML or save a config file.

Or run it locally (pnpm monorepo β€” packages aren't published to npm yet):

pnpm install
pnpm build
pnpm test
# then open apps/playground/public/index.html in any browser
What you can do in the editor
  • Start from a template β†’ 8 ready-made styles (or blank), then make it yours.
  • Tap any text β†’ a contextual inspector to change its content, font, color, size and weight (saved per-element in styleOverrides); double-tap to edit text inline.
  • Tap a sticker β†’ a Photoshop-style frame: corner handles scale, a top handle rotates, two-finger pinch on touch; drag to move with alignment snapping.
  • Drag the card edges β†’ change width / top / bottom padding.
  • Drag a section (or use the layout-order ↑/↓ panel) β†’ reorder blocks (blockOrder).
  • Upload a logo / background (background is scalable, rotatable, transparent-able), pick colors & fonts, toggle a transparent background / card / QR backing, switch custom / thermal, save/restore a config, and download PNG with the fonts embedded so the export matches the preview.

The editor only mutates the receipt model β€” exports stay deterministic and editor-metadata-free.

πŸ“¦ Packages

Package What it does
@receipt-engine/core Schema, validation, normalization, totals.
@receipt-engine/themes Built-in themes + getTheme / mergeTheme.
@receipt-engine/render-svg Receipt β†’ SVG string (canonical).
@receipt-engine/render-html Receipt β†’ standalone HTML.
@receipt-engine/render-png Receipt β†’ PNG Buffer (resvg, server-side).
@receipt-engine/bitmap 1-bit dithering + bit-packing for thermal printers.
@receipt-engine/escpos ESC/POS commands + raster output (GS v 0).
@receipt-engine/connect Browser delivery: Web Bluetooth thermal print, canvas PNG, Web Share.
@receipt-engine/import POS / order β†’ receipt adapters (incl. OpenBooth) + template overlay.
@receipt-engine/react <ReceiptCard />.
@receipt-engine/cli receipt-engine render ….

Apps: apps/playground β€” the static in-browser editor (deployed above) Β· apps/openbooth-bridge β€” the OpenBooth ⇄ receipt-engine integration bundle.

πŸ§‘β€πŸ’» Use it as a library

import { renderReceiptToSvg } from '@receipt-engine/render-svg'
import { renderReceiptToPng } from '@receipt-engine/render-png'

const svg = renderReceiptToSvg(receipt, { theme: 'custom', width: 720 })
const png = await renderReceiptToPng(receipt, { theme: 'custom', pixelRatio: 2 })
import { ReceiptCard } from '@receipt-engine/react'

export const App = () => <ReceiptCard receipt={receipt} theme="custom" width={360} />
CLI
# from the repo, the CLI runs via the dev script:
pnpm --filter @receipt-engine/cli dev render examples/cute-booth/receipt.json --theme custom --format svg --out receipt.svg

# once built, the bin is available:
receipt-engine render receipt.json --theme custom --format png --out receipt.png

Options: --theme custom|thermal, --format svg|html|png, --out <path>, --width <number>, --pretty. svg/html print to stdout when --out is omitted.

Theme customization
import { getTheme, mergeTheme } from '@receipt-engine/themes'
import { renderReceiptToSvg } from '@receipt-engine/render-svg'

const theme = mergeTheme(getTheme('custom'), {
  palette: { primary: '#0b7285', accent: '#0b7285' },
})
const svg = renderReceiptToSvg(receipt, { theme })

πŸ“„ Receipt JSON

{
  "schemaVersion": "0.1",
  "currency": "TWD",
  "merchant": { "name": "Mimito Booth", "subtitle": "ζ‰‹δ½œ Γ— 插畫 Γ— 小θͺŒ", "logo": "./assets/logo.svg" },
  "event": { "name": "Artist Alley", "boothNumber": "A12" },
  "transaction": { "receiptNo": "AA-A12-018", "issuedAt": "2026-06-01T14:30:00+08:00" },
  "items": [
    { "name": "Sticker Set", "quantity": 2, "unitPrice": 120, "tags": ["ζ–°εˆŠ"] },
    { "name": "Mini Zine", "quantity": 1, "unitPrice": 180, "tags": ["η‰Ήε…Έ"] }
  ],
  "discounts": [{ "label": "Set deal", "amount": 50 }],
  "payments": [{ "method": "Cash", "amount": 700 }],
  "qr": { "value": "https://instagram.com/mimito.art", "label": "θΏ½θΉ€ζˆ‘ε€‘" },
  "message": { "title": "Thank you!", "body": "ζ„Ÿθ¬ζ”―ζŒζˆ‘ε€‘ηš„ζ”€δ½οΌ" }
}

Full field reference in docs/schema.md. Ready-made examples live in examples/ (simple, cute-booth, openbooth-like).

πŸ“± Using it on a phone

The rendering paths are pure front-end JavaScript β€” SVG, HTML, and PNG (canvas, via @receipt-engine/connect) all run directly in a mobile browser, no server required. That's how the playground renders, exports PNG, and even thermal-prints over Web Bluetooth on a phone. (@receipt-engine/render-png is a separate server-side path using a native module, for batch / Node.)

The simplest way to use it: open the deployed editor on your phone. To embed rendering in your own app (React Native / WebView), import @receipt-engine/render-svg or @receipt-engine/render-html directly.

πŸ“š Docs

Schema Β· Themes Β· Rendering Β· Roadmap

πŸ—ΊοΈ Roadmap

Shipped (v0.1) in-browser editor Β· browser PNG export Β· ESC/POS thermal print over Web Bluetooth Β· OpenBooth integration Β· δΈ­/ζ—₯/θ‹± i18n. Next hosted receipt pages Β· coupon QR Β· community themes Β· plugin system. Full list in docs/roadmap.md.

πŸ“œ License

MIT Β© mimito

About

Receipts, but delightful. Render beautiful digital receipt cards, SVG/HTML previews, PNG images, and future thermal-printer output from structured receipt JSON.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages