Doc Variables
← Back to Resources

How to Create a Google Docs Invoice Template (and Generate Invoices Automatically)

How to Create a Google Docs Invoice Template (and Generate Invoices Automatically)

How to Create a Google Docs Invoice Template (and Generate Invoices Automatically)

The Invoice Problem Every Freelancer and Small Business Has

Every time a project wraps up, the same ritual begins. Open last month's invoice. Save a copy. Update the client name. Change the date. Swap out the line items. Update the total. Fix the invoice number. Double-check nothing from the last client leaked into this one. Save. Export to PDF. Send.

For one invoice, that's 10 minutes. For ten invoices a month, that's nearly two hours of pure busywork — high-friction, error-prone, and completely automatable.

This guide covers how to build a proper Google Docs invoice template with variables, and then how to automate invoice generation so you can produce a finished, accurate invoice in seconds instead of minutes.

What Makes a Good Invoice Template

Before building, understand what a solid invoice template needs:

  • Business information: Your name/company, address, email, phone, logo
  • Client information: Client name, company, billing address
  • Invoice metadata: Invoice number, issue date, due date, payment terms
  • Line items: Description, quantity, rate, amount per line
  • Totals: Subtotal, tax (if applicable), total due
  • Payment details: How to pay (bank transfer, PayPal, Stripe link, check)
  • Notes: Late payment terms, thank you message, project reference

A good template has all of these elements designed once — and every new invoice just swaps out the variable data.

Building Your Google Docs Invoice Template with Doc Variables

Doc Variables is a Google Docs add-on that replaces placeholder variables in your template with real data. It's the cleanest way to handle invoice generation without leaving Google Docs.

Step 1: Create the Template Document

Create a new Google Doc. Design your invoice layout — header, table for line items, totals section, footer. Use whatever formatting represents your brand.

For every piece of data that changes per invoice, insert a Doc Variables placeholder using double curly braces:

INVOICE

From:
Your Business Name
[email protected]

Bill To:
{{Client Name}}
{{Client Company}}
{{Client Address}}

Invoice #: {{Invoice Number}}
Date: {{Invoice Date}}
Due Date: {{Due Date}}
Payment Terms: Net {{Payment Terms}}

---------------------------------------
Description          Qty    Rate    Amount
---------------------------------------
{{Service 1}}        {{Qty 1}}  {{Rate 1}}  {{Amount 1}}
{{Service 2}}        {{Qty 2}}  {{Rate 2}}  {{Amount 2}}
{{Service 3}}        {{Qty 3}}  {{Rate 3}}  {{Amount 3}}
---------------------------------------
Subtotal:                           {{Subtotal}}
Tax ({{Tax Rate}}%):                {{Tax Amount}}
Total Due:                          {{Total Due}}

Payment Instructions:
{{Payment Instructions}}

Notes: {{Notes}}

Thank you for your business, {{Client First Name}}!

This template has 18 variables. Every invoice is unique because the variables change — the design and formatting stay identical.

Step 2: Install Doc Variables

In your template document: Extensions → Add-ons → Get add-ons → Search "Doc Variables" → Install. Authorize when prompted.

Step 3: Use the Sidebar to Generate One Invoice

Open the Doc Variables sidebar: Extensions → Doc Variables → Start. A form appears with a field for every variable in your template. Fill it out, click Replace Variables — and your invoice is instantly populated.

This works great for one-off invoices. But for regular billing, there's a better approach.

Automating Invoice Generation from a Google Sheet

If you bill multiple clients regularly, keep your client and project data in a Google Sheet and generate all invoices at once — or automatically when data is entered.

Setting Up Your Invoice Spreadsheet

Create a Google Sheet with column headers that exactly match your template variable names:

  • Client Name
  • Client Company
  • Client Address
  • Client First Name
  • Invoice Number
  • Invoice Date
  • Due Date
  • Payment Terms
  • Service 1
  • Qty 1
  • Rate 1
  • Amount 1
  • Service 2
  • Qty 2
  • Rate 2
  • Amount 2
  • Subtotal
  • Tax Rate
  • Tax Amount
  • Total Due
  • Payment Instructions
  • Notes

Each row is one invoice. Fifty clients = fifty invoices. You enter the data once; automation handles the rest.

Using Doc Variables' Batch Generation

Open your invoice template in Google Docs → Extensions → Doc Variables → Generate from Spreadsheet. Select your spreadsheet, select the rows you want to invoice (or all of them), choose an output folder in Google Drive, and click Generate.

Doc Variables creates one invoice document per row, replaces all variables with the row's data, and saves each file to your output folder — named automatically from the client name and invoice number.

Monthly billing that used to take 2+ hours takes under 5 minutes.

Building an Invoice Automation with Google Apps Script

For full control — auto-incrementing invoice numbers, automatic PDF export, email delivery — Google Apps Script handles it all.

The Complete Invoice Automation Script

function generateInvoices() {
  var TEMPLATE_DOC_ID = 'YOUR_INVOICE_TEMPLATE_DOC_ID';
  var OUTPUT_FOLDER_ID = 'YOUR_OUTPUT_FOLDER_ID';
  var SHEET_NAME = 'Invoices';
  
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName(SHEET_NAME);
  var data = sheet.getDataRange().getValues();
  var headers = data[0];
  
  var template = DriveApp.getFileById(TEMPLATE_DOC_ID);
  var outputFolder = DriveApp.getFolderById(OUTPUT_FOLDER_ID);
  
  // Process rows where "Generated" column (last col) is empty
  var generatedColIndex = headers.indexOf('Generated');
  
  for (var i = 1; i < data.length; i++) {
    var row = data[i];
    
    // Skip if already generated or empty
    if (!row[0] || row[generatedColIndex]) continue;
    
    // Build variable map
    var vars = {};
    headers.forEach(function(h, idx) {
      var val = row[idx];
      if (val instanceof Date) {
        val = Utilities.formatDate(val, 'America/Chicago', 'MMMM d, yyyy');
      }
      vars[h] = val !== undefined && val !== null ? String(val) : '';
    });
    
    // Name the invoice file
    var fileName = 'Invoice ' + vars['Invoice Number'] + ' — ' + vars['Client Company'];
    
    // Copy template
    var newFile = template.makeCopy(fileName, outputFolder);
    var doc = DocumentApp.openById(newFile.getId());
    var body = doc.getBody();
    
    // Replace all variables
    Object.keys(vars).forEach(function(key) {
      body.replaceText('\\{\\{' + key + '\\}\\}', vars[key]);
    });
    
    doc.saveAndClose();
    
    // Export as PDF
    var pdf = newFile.getAs('application/pdf');
    var pdfFile = outputFolder.createFile(pdf.setName(fileName + '.pdf'));
    
    // Email the invoice
    if (vars['Client Email']) {
      MailApp.sendEmail({
        to: vars['Client Email'],
        subject: 'Invoice #' + vars['Invoice Number'] + ' from Your Business Name',
        body: 'Hi ' + vars['Client First Name'] + ',\n\nPlease find your invoice attached. Payment is due ' + vars['Due Date'] + '.\n\nThank you for your business!\n\nBest,\nYour Name',
        attachments: [pdf]
      });
    }
    
    // Mark row as generated
    sheet.getRange(i + 1, generatedColIndex + 1).setValue(new Date());
    
    Logger.log('Generated: ' + fileName);
  }
}

Add a "Generated" column to your spreadsheet. The script processes only rows that haven't been generated yet — so you can add new clients to the sheet and run the script again without re-generating old invoices.

Auto-Incrementing Invoice Numbers

Rather than manually entering invoice numbers, auto-generate them:

function getNextInvoiceNumber() {
  var props = PropertiesService.getScriptProperties();
  var current = parseInt(props.getProperty('invoiceCounter') || '999');
  var next = current + 1;
  props.setProperty('invoiceCounter', String(next));
  return 'INV-' + String(next).padStart(4, '0');
  // Returns: INV-1000, INV-1001, INV-1002, etc.
}

// Use in your main script:
vars['Invoice Number'] = getNextInvoiceNumber();

Invoice numbers are sequential, persistent, and you never have to think about them again.

Calculating Invoice Totals Automatically in Google Sheets

Let Google Sheets do the math so you never have a calculation error on an invoice.

Formula Columns for Totals

Add calculated columns alongside your data columns:

  • Amount 1: =IF(C2,D2*E2,"") (Qty × Rate, blank if no quantity)
  • Amount 2: =IF(F2,G2*H2,"")
  • Amount 3: =IF(I2,J2*K2,"")
  • Subtotal: =SUM(L2,N2,P2) (sum of all Amount columns)
  • Tax Amount: =IF(R2,Q2*(R2/100),0) (Subtotal × Tax Rate)
  • Total Due: =Q2+S2

Format the currency columns with =TEXT(Q2,"$#,##0.00") helper columns so amounts arrive in the document pre-formatted.

The math is done before the document generates. Zero chance of a calculation error in the final invoice.

Invoice Template Variations: Use Cases Beyond Freelancing

Agency Retainer Invoices

Monthly retainer billing is perfectly repetitive. Your line items are the same every month — just the date, invoice number, and billing period change. Build one template, maintain one sheet row per client with monthly retainer data, and generate all retainer invoices in one click at month-end.

Variables: {{Client Name}}, {{Billing Period}}, {{Retainer Amount}}, {{Invoice Number}}, {{Due Date}}

Project Milestone Invoices

For projects billed in phases, include milestone-specific variables:

Variables: {{Project Name}}, {{Milestone}}, {{Milestone Description}}, {{Milestone Amount}}, {{Completion Percentage}}, {{Next Milestone}}

Contractor Invoices for Multiple Services

Contractors billing clients for a mix of consulting, implementation, and travel need flexible line items. Use numbered variables (Service 1 through Service 6) with conditional sections so empty lines don't appear:

{{#if Service 2}}
{{Service 2}}  {{Qty 2}}  {{Rate 2}}  {{Amount 2}}
{{/if}}

International Invoices

For international clients, include additional fields:

Extra variables: {{Currency}}, {{VAT Number}}, {{Exchange Rate}}, {{Amount in USD}}, {{SWIFT Code}}

Recurring Subscription Invoices

SaaS businesses and subscription services billing annual or monthly contracts:

Variables: {{Plan Name}}, {{Billing Cycle}}, {{Seats}}, {{Price Per Seat}}, {{Subscription Period}}, {{Renewal Date}}

Advanced Invoice Automation Techniques

Google Form → Invoice Workflow

If clients submit project requests or service orders via Google Form, you can auto-generate a draft invoice from that form submission:

  1. Client submits a project intake form
  2. Apps Script detects the new form response
  3. Script calculates estimated invoice amount based on form answers
  4. Script generates a draft invoice from the template
  5. You receive a notification with a link to review and approve
  6. You click send — the client gets their invoice

The invoice was drafted while you were still on the call with the client.

Overdue Invoice Reminders

Build an automated reminder system:

function checkOverdueInvoices() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Invoices');
  var data = sheet.getDataRange().getValues();
  var headers = data[0];
  
  var today = new Date();
  var dueDateCol = headers.indexOf('Due Date');
  var paidCol = headers.indexOf('Paid Date');
  var emailCol = headers.indexOf('Client Email');
  var clientCol = headers.indexOf('Client First Name');
  var amountCol = headers.indexOf('Total Due');
  var invoiceCol = headers.indexOf('Invoice Number');
  
  for (var i = 1; i < data.length; i++) {
    var row = data[i];
    var dueDate = new Date(row[dueDateCol]);
    var isPaid = row[paidCol];
    
    if (!isPaid && dueDate < today) {
      var daysOverdue = Math.floor((today - dueDate) / (1000 * 60 * 60 * 24));
      
      MailApp.sendEmail({
        to: row[emailCol],
        subject: 'Friendly reminder: Invoice #' + row[invoiceCol] + ' is ' + daysOverdue + ' days overdue',
        body: 'Hi ' + row[clientCol] + ',\n\nThis is a friendly reminder that invoice #' + row[invoiceCol] + ' for ' + row[amountCol] + ' was due on ' + row[dueDateCol] + '.\n\nPlease let me know if you have any questions.\n\nThank you,\nYour Name'
      });
    }
  }
}

Run this on a daily trigger. Overdue invoices get automatic reminders without you having to track them manually.

Invoice Status Dashboard

Add status columns to your sheet and build a simple dashboard:

  • Generated: Date invoice was created (auto-populated by script)
  • Sent: Date invoice was emailed (auto-populated)
  • Paid Date: Date payment received (manual entry)
  • Days to Pay: =IF(F2,F2-C2,"") (Paid Date minus Invoice Date)
  • Status: =IF(F2,"Paid",IF(D2<TODAY(),"Overdue","Pending"))

Conditional formatting: red for Overdue, green for Paid, gray for Pending. You always know exactly where every invoice stands.

Common Mistakes to Avoid

Mistake 1: Not Using a Template — Working from a Copy

The most common invoice mistake: "I'll just edit last month's invoice." One missed update means the wrong client's name, wrong dates, or — worst case — the wrong bank details on an invoice you've already sent. Always work from a true template with variable placeholders, never a modified copy of a real invoice.

Mistake 2: Inconsistent Variable Names

If your sheet column says "Invoice Date" but your template uses {{invoice_date}}, the replacement fails. Copy column headers directly into template variables — don't retype them.

Mistake 3: Forgetting Date Formatting

Dates from Google Sheets often arrive as raw serial numbers (like 46,559) unless you handle formatting. Use a TEXT formula column in Sheets:

=TEXT(C2, "MMMM d, yyyy")

Reference the formatted column in your template variables.

Mistake 4: No Invoice Number System

"Invoice for Jane" is not an invoice number. Sequential invoice numbers (INV-1001, INV-1002) make accounting, disputes, and tax filing dramatically easier. Automate them from day one.

Mistake 5: Plain Google Docs — No PDF Export

Clients shouldn't be editing your invoice. Always send invoices as PDFs. In Apps Script, export to PDF automatically as part of the generation process, or right-click the generated file in Drive → Download as PDF.

Setting Up Your Invoice System Today: 30-Minute Quickstart

Minutes 0–5:
Create a new Google Doc. Add your business info, design a simple invoice layout. Insert {{variable}} placeholders for every piece of client data.

Minutes 5–10:
Create a Google Sheet with column headers matching your variable names. Add 3–5 test clients with sample data.

Minutes 10–15:
Install Doc Variables → Extensions → Doc Variables → Generate from Spreadsheet → Select your sheet → Pick a test row → Generate.

Minutes 15–20:
Open the generated invoice. Verify all variables populated correctly. Adjust any formatting that needs cleaning up.

Minutes 20–30:
Set up calculated columns in your sheet for totals, formatted dates, and invoice numbers. Re-test with clean data.

At the end of 30 minutes, you have a working invoice system. Future invoices take 2 minutes to generate and are error-free every time.

From Template to Automated Invoice Machine

A Google Docs invoice template eliminates the formatting rework. Variable placeholders eliminate the manual data entry. Automation eliminates even the step of opening the sidebar.

The progression looks like this:

  1. Template only: Open template, fill sidebar, replace variables. ~5 minutes per invoice.
  2. Template + Sheet: Enter data in sheet, batch-generate. ~30 seconds per invoice.
  3. Full automation: Enter data in sheet, script auto-generates + emails PDF. ~10 seconds per invoice.

Start wherever makes sense for your volume. A solo freelancer with 5 monthly invoices gets everything they need from step 1. An agency billing 50+ clients monthly benefits from the full automation in step 3.

Either way: build the template right, and you'll never recreate an invoice from scratch again.


Doc Variables makes Google Docs invoice automation simple — build your template once, connect your data, and generate professional invoices in bulk in seconds. Try it free at docvars.com.

Ready to try Doc Variables?

Join 190,000+ users creating amazing Google Doc templates.

Install Now - It's Free