How to Automate Your Invoice Generation in 30 Minutes

If you’re a freelancer or small agency, you’ve probably spent a painful afternoon every month creating invoices. You copy client names, amounts, and dates into a template, then export to PDF. It’s mind-numbing, and it’s exactly the kind of work that should be automated. In this post, I’ll show you a script that turns that two-hour chore into a 30-second command.

First, let’s be clear: this isn’t a tutorial on using Zapier or Make. Those tools are great, but they can get pricey and they have their own learning curve. Instead, I’m going to give you a Python script that reads from a CSV file (which you can export from your billing tool like Stripe, FreshBooks, or even a spreadsheet) and generates a clean PDF invoice for each row.

### Why Python?

Python is probably already installed on your machine if you’re on macOS or Linux. On Windows, you might need to install it, but it’s a one-time thing. The script uses two libraries: `csv` (built-in) and `reportlab` (for PDF generation). You’ll need to install `reportlab` with pip, but that’s a single command.

The beauty of a script like this is that you control everything. You can tweak the layout, add your logo, change the color scheme. You’re not locked into a third-party template.

### The Script

Here’s the core of it: you define a template function that takes a dictionary of invoice data (client name, email, items, total) and returns a PDF. Then you loop through each row in your CSV. It’s about 60 lines total. I’ve included comments so you can adjust the layout without reading a full library reference.

I’ve used this exact script for my own consulting work for the past year. It’s saved me dozens of hours, and it’s also reduced errors—no more typos in the total or the client’s address.

### A Real-World Example

Let’s say you export your Stripe payments to CSV. Each row has the customer’s email, the amount, and the date. You can map those fields directly to your invoice script. Run it, and you get a PDF per transaction (or aggregated by customer if you prefer).

One thing to watch out for: if you have discounts or taxes, you’ll need to add those fields to your CSV or modify the script to calculate them. But that’s a small change.

### Next Steps

Automating your invoices is just the first step. Once you have the script, you can schedule it to run weekly using cron (on macOS/Linux) or Task Scheduler (on Windows). Then you’ll have a folder full of ready-to-send PDFs every Monday morning.

If you don’t want to build this from scratch, we’ve packaged a ready-to-run version with a clean template and a setup guide. It takes about 10 minutes to get it working. Grab it from our library and say goodbye to manual invoicing for good.