Mobile-first web application for generating, previewing, printing, saving, and managing history of barcodes (EAN-13, UPC, Code 128) using pure frontend technologies.
- Generate valid random EAN-13 and UPC codes (with correct check digit)
- Support for Code 128 arbitrary alphanumeric values
- Manual entry with validation per barcode type
- Step-based UX (Generate -> Preview -> History)
- Live barcode rendering via JsBarcode
- Print multiple copies with selectable label size
- Save barcode as PNG image
- Local history (persisted in
localStorage, capped at 50 items) with one-click reprint - Responsive, mobile-first Tailwind UI
- HTML + Vanilla JavaScript (no build framework required)
- JsBarcode for barcode rendering
- Tailwind CSS for styling (custom component classes via
@layer components) - Live development via
live-server
barcode-gen/
├── index.html # Main application (logic + UI)
├── src/
│ └── input.css # Tailwind source (components layer)
├── style.css # Generated Tailwind CSS output
├── tailwind.config.js # Tailwind config (content paths + primary palette)
├── postcss.config.js # PostCSS / Tailwind runner config
├── package.json # Scripts & dependencies
└── node_modules/ # Installed packages
npm installnpm run buildOr watch for changes during development:
npm run build:cssnpm startThis serves index.html (default: http://127.0.0.1:8080 or similar port shown in console).
Alternatively you can drop the folder into any static server (XAMPP/Apache, nginx, etc.). Ensure
style.cssis built first.
- Click Create New Barcode or Generate Random Barcode
- Choose a barcode type (EAN-13, UPC, Code 128)
- (If manual) enter a value:
- EAN-13: exactly 13 digits (last digit can be auto-generated externally if needed)
- UPC: exactly 12 digits
- Code 128: any 1+ character alphanumeric string (current random set: A–Z, 0–9)
- Button Next: Preview activates once input passes validation
- In Preview step:
- Adjust Label Size (UI selection currently cosmetic; logic placeholder for future scaling)
- Set Number of Copies
- Click Print (opens printable window & triggers system print) OR Save (downloads PNG)
- After action you’re taken to History where previous barcodes appear (newest first)
- Use Reprint to jump back to Preview for that barcode
- Click Generate New Barcode to begin again
- EAN-13: Generates 12 random digits, computes check digit using weight pattern (1,3,...)
- UPC: Generates 11 random digits, computes check digit using standard weighting
- Code 128: Random 6–13 length string from A–Z0–9 (subset of full spec for simplicity)
History is stored in localStorage under key barcodeHistory (array of up to 50 records). Clearing browser storage resets history.
Defined in src/input.css under @layer components:
.step-card.btn-primary.btn-secondary.form-select.form-input.barcode-item
Update styles then rebuild CSS (npm run build).
- Add
<option>to the#barcode-typeselect - Extend
generateRandomBarcode()and validators invalidateBarcodeInput() - Confirm JsBarcode supports the format (see docs)
Modify the inline <style> template inside printBarcode() for page margins, sizing, or label formatting.
Since it’s static:
- Run
npm run build - Deploy
index.html,style.css, andnode_modules/jsbarcode/dist/JsBarcode.all.min.js(or bundle that file separately) - (Optional) Inline or self-host
JsBarcodein avendor/folder to avoid shipping fullnode_modules
- Scale canvas / label size dynamically based on selected size
- Add QR or DataMatrix support (would need different library)
- Drag-and-drop batch generation
- Export history (JSON/CSV)
- Dark mode toggle
- PWA install capability & offline caching
- Accessibility enhancements (focus states, aria labels)
- Fork and clone
- Create a feature branch:
git checkout -b feature/your-feature - Make changes +
npm run build - Commit & push, open PR
Please keep PRs focused and include a brief summary.
MIT © 2025
Enjoy building! Let me know if you’d like CI, tests, or added formats.