Home / E-commerce and Business / Invoice Generator

Invoice Generator in JavaScript, Free with Live Demo

Free invoice generator in plain JavaScript. Edit your details, add line items, set tax and discount, pick a currency and due date, and print a clean PDF. Saved in your browser.

Open live demoDownload HTML fileView code on GitHub
Invoice Generator JavaScript project: an editable invoice that does the maths and prints to a clean PDF

Runs on: Print CSS and localStorage. Works in all modern browsers. Use the print dialog and choose Save as PDF.

What is the Invoice Generator?

An invoice you edit directly on the page: your details, the client, the project, line items with quantity and rate, discount, tax and notes.

Totals update as you type, dates fill in by themselves, the currency can be changed, and printing or saving as PDF gives a clean page without buttons.

Good for

  • Freelancers and small studios
  • Quotes and estimates
  • Small shops without billing software
  • Internal recharge notes

What this project does

How it works

  1. Type on the pageNames, addresses and descriptions are contenteditable, so the invoice itself is the form. Numbers use small inputs.
  2. One calc functionEvery change runs calc(): line amounts, subtotal, discount, tax and total, then saves everything to localStorage.
  3. Print CSS hides the restA print media query hides the whole page except the invoice, and removes buttons and input borders, so Save as PDF looks clean.

The key JavaScript

This is the heart of the project. The full file has the rest, including the screen layout and error handling.

function calc() {
  const sub = rows.reduce((a, r) => a + r.qty * r.rate, 0);
  const discount = sub * discountPct / 100;
  const tax = (sub - discount) * taxPct / 100;
  total.textContent = money(sub - discount + tax);
  localStorage.setItem("invoice", JSON.stringify(data));
}
/* print only the invoice */
@media print {
  body * { visibility: hidden; }
  .invoice, .invoice * { visibility: visible; }
}

How to use it

  1. Click Download HTML file above.
  2. Open the file in a code editor, like VS Code.
  3. Run it from a local server with npx serve . so the camera, microphone and AI features are allowed.
  4. Change the text and colors, then upload it to GitHub Pages, Netlify or your own site. It is one file with no build step.

Questions people ask

How do I make a PDF?

Click Print or save PDF and pick Save as PDF in the print dialog. The print styles hide everything except the invoice.

Is my invoice saved?

Yes, in localStorage in your browser. It is still there next time you open the page on the same device.

Can I add my logo?

Yes. Put an img tag in the header. It will print with the invoice.

More E-commerce and Business projects