As a freelancer, I've used my share of invoicing tools — Wave, FreshBooks, even good old Excel templates. They all work, but they all have the same problem: you need to sign up, give away your data, and deal with feature bloat just to send a simple PDF invoice.
So I built my own. In a single HTML file. No backend, no sign-up, no tracking. Just open it in your browser and start invoicing.
In this post, I'll walk you through how I built it, the libraries I used, and why going fully client-side was the best decision.
The Problem I Was Solving
Most freelancers need invoices that:
- Look professional
- Calculate totals automatically (subtotal, tax, discount)
- Export to clean PDFs
- Work offline
- Don't require signing up for anything
None of the free tools I tried checked all those boxes without some compromise. So I asked: what if an entire invoicing app lived in one HTML file?
The Tech Stack (3 Libraries, Zero Backend)
1. Tailwind CSS (via CDN) — for styling
I didn't want to write hundreds of lines of CSS. Tailwind's utility classes let me build a clean, responsive layout in minutes. Loaded via CDN:
<script src="https://cdn.tailwindcss.com"></script> 2. html2pdf.js — for PDF generation
This is the magic. It combines html2canvas (screenshot the DOM) with jsPDF (render to PDF). The result: pixel-perfect PDF export of whatever's on screen.
html2pdf().set({ margin: 10, filename: `invoice-${invoiceNumber}.pdf`, html2canvas: { scale: 2 }, jsPDF: { format: 'a4', orientation: 'portrait' } }).from(element).save(); 3. Vanilla JavaScript — for all the logic
No React, no Vue, no build step. Just DOM manipulation and event listeners.
Key Features I Implemented
Dynamic Line Items
Add or remove line items on the fly. Each row has description, quantity, and rate. Totals update in real-time:
function calculateTotals() { let subtotal = 0; document.querySelectorAll('.line-item').forEach(row => { const qty = parseFloat(row.querySelector('.qty').value) || 0; const rate = parseFloat(row.querySelector('.rate').value) || 0; subtotal += qty * rate; }); const tax = subtotal * (taxRate / 100); const discount = parseFloat(discountInput.value) || 0; const total = subtotal + tax - discount; // Update DOM... } Multi-Currency Support
A dropdown lets you pick from 20+ currencies (USD, EUR, GBP, VND, JPY, etc.). The symbol updates automatically on the invoice preview.
3 Professional Templates
- Classic — Traditional layout with bordered table
- Modern — Clean gradient header, minimal design
- Minimal Pro — Ultra-clean, lots of whitespace
Switch templates with one click — the PDF regenerates instantly.
Local Storage Persistence
Your data stays in localStorage. Close the tab, come back tomorrow — everything's still there. No account needed.
Full Offline Support
Once loaded, it works without internet. Perfect for working from cafes with spotty WiFi.
Why Client-Side Only?
I deliberately avoided a backend because:
- Privacy — Invoice data contains sensitive business info. Keeping it in the browser means zero exposure.
- Speed — No API calls, no loading spinners. Everything is instant.
- Cost — No server to maintain. The file can be hosted anywhere for free (GitHub Pages, Cloudflare Pages, even emailed to yourself).
- Reliability — Works even if hosting goes down. You can save the HTML file and use it forever.
Lessons Learned
1. PDF quality matters
html2canvas at default scale produces blurry text. Setting scale: 2 fixed this — the PDF now renders at 2x resolution.
2. CSS print styles are tricky
What looks good on screen doesn't always print well. I had to add @media print overrides and test extensively.
3. localStorage has limits
The 5MB limit is plenty for invoice data, but I added error handling in case users try to store unusually large amounts.
4. Vanilla JS is underrated
For a self-contained tool like this, React would've been overkill. Vanilla JS kept the file small and dependency-free.
What's Next?
I'm considering adding:
- Recurring invoice templates — Save client/item combos for repeat use
- CSV import — Bulk-add line items from a spreadsheet
- Dark mode — Because why not
- Payment tracking — Mark invoices as paid/unpaid
Try It Yourself
The entire app is a single HTML file. You can:
- Download the source from GitHub
- Or just save the HTML file locally and open it in any browser
No install. No sign-up. Just invoicing.
If you found this useful, share it with a freelancer friend who's still struggling with clunky invoicing tools. And if you have feature requests, drop them in the comments!
Tags: #JavaScript #HTML #CSS #WebDev #Freelancing #Productivity #OpenSource