How to generate an invoice number

Use a simple sequence that never repeats and doesn't skip, such as INV-2026-001, INV-2026-002, and keep a log of every number you issue. Many tax systems expect invoice numbers to be unique and sequential, so avoid random IDs. Our free Invoice Maker has an Invoice # field you fill in; it doesn't count for you, so keep the log in a sheet or let your code hand out the next number.

Open the tool Invoice Maker — free online tool · Free

Formats that work

FormatExampleGood for
Plain counter0001, 0002Very small businesses
Year and counterINV-2026-014Most freelancers; resets cleanly each year
Client code and counterACME-007A few big clients who want their own series
Date and counter20261130-01Many invoices a day

Rules to follow

The next number in Excel or Google Sheets

If column A holds the numbers you've issued and A2 is the last one (INV-2026-014):

="INV-2026-"&TEXT(VALUE(RIGHT(A2,3))+1,"000")

Count this year's invoices instead (put it outside column A):
="INV-"&YEAR(TODAY())&"-"&TEXT(COUNTIF(A:A,"INV-"&YEAR(TODAY())&"-*")+1,"000")

The next number in code

Two people (or two server requests) must never get the same number. A counter table updated inside one transaction prevents that. Pass the result as invoice_number to our Invoice PDF API, where it's required (up to 40 characters) and printed in the header.

import sqlite3, datetime

db = sqlite3.connect("billing.db", isolation_level=None)
db.execute("CREATE TABLE IF NOT EXISTS counters (year INTEGER PRIMARY KEY, last INTEGER NOT NULL)")

def next_invoice_number() -> str:
    year = datetime.date.today().year
    db.execute("BEGIN IMMEDIATE")  # locks the table until COMMIT
    db.execute("INSERT INTO counters (year, last) VALUES (?, 0) ON CONFLICT(year) DO NOTHING", (year,))
    db.execute("UPDATE counters SET last = last + 1 WHERE year = ?", (year,))
    n = db.execute("SELECT last FROM counters WHERE year = ?", (year,)).fetchone()[0]
    db.execute("COMMIT")
    return f"INV-{year}-{n:04d}"

Using it in the Invoice Maker

  1. Open /tools/invoice-maker. The Invoice # field starts at INV-001.
  2. Type your next number from your log.
  3. Fill in the client and items, then Save as PDF.
  4. Write the number, client, amount and date in your log straight away.

The product

Questions

Can I start at a number other than 1?

Yes. Starting at 1001 or 0100 is common and fine, as long as you count up from there without gaps.

What if I made a mistake on an invoice I already sent?

Leave its number in your records, issue a credit note that cancels it, and send a corrected invoice with the next number.

Does the Invoice Maker remember my last number?

No. Nothing is saved between visits, so the number comes from your own log.

Related

Updated 2026-12-01