Free GST Invoice Generator with PDF Download and Saved Invoice History
GST Invoice Generator
Create, customize, and download GST-compliant invoices for India — instantly
✓ GST Compliant
Saved invoices in History are stored in this browser only (no server/database in this version). Clearing your browser data will remove them — use Export if you need a permanent backup.
Company Logo & Signature
Invoice Details
Seller (Your Company)
Buyer (Client)
Items / Products / Services
IGST (Interstate — buyer in a different state)
CGST + SGST (Intrastate)
DescriptionHSN/SACQtyRate (₹)GST %Amount
Subtotal₹0.00
CGST₹0.00
SGST₹0.00
IGST₹0.00
Discount- ₹
Grand Total₹0.00
Bank Details & Notes
Grand Total
₹0.00
Fill in the Invoice Form, then click "Generate Preview"
'+
''+
'
';
return;
}
list.innerHTML = rows.map(function(r){
var amt = parseFloat(r.grand_total) || 0;
var dateStr = r.invoice_date || (r.updated_at ? r.updated_at.split('T')[0] : '');
return 'No saved invoices yet. Generate a preview and click "Save to History" to see it here.
'+ ''+
''+
'
';
}).join('');
list.querySelectorAll('[data-open]').forEach(function(btn){
btn.addEventListener('click', function(){ openHistoryInvoice(btn.dataset.open); });
});
list.querySelectorAll('[data-del]').forEach(function(btn){
btn.addEventListener('click', function(){ deleteHistoryInvoice(btn.dataset.del); });
});
}
function openHistoryInvoice(id){
var list = readHistory();
var row = list.find(function(r){ return r.id === id; });
if(!row){ showToast('Invoice not found'); return; }
applyFormData(row.data || {});
currentHistoryId = row.id;
calcTotals();
switchTab('form', root.querySelectorAll('.tab')[0]);
showToast('Invoice loaded — you can edit and re-save it');
}
function deleteHistoryInvoice(id){
if(!confirm('Delete this invoice from your history? This cannot be undone.')) return;
var list = readHistory().filter(function(r){ return r.id !== id; });
writeHistory(list);
if(currentHistoryId === id){ currentHistoryId = null; }
showToast('Invoice deleted');
loadHistory($('gip_history_search').value.trim());
}
$('gip_history_export').addEventListener('click', function(){
var list = readHistory();
if(!list.length){ showToast('No saved invoices to export'); return; }
var blob = new Blob([JSON.stringify(list, null, 2)], {type:'application/json'});
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = 'gst-invoice-history-backup.json';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
showToast('Backup file downloaded');
});
var historySearchTimer;
$('gip_history_search').addEventListener('input', function(){
clearTimeout(historySearchTimer);
var val = this.value.trim();
historySearchTimer = setTimeout(function(){ loadHistory(val); }, 250);
});
/* ---- reset ---- */
$('gi_reset').addEventListener('click', function(){
if(!confirm('Reset the entire form? All unsaved data will be lost.')) return;
items = [];
logoData = ''; signData = ''; currentHistoryId = null;
$('gi_logo_preview').innerHTML = $('gi_logo_preview').getAttribute('data-default');
$('gi_sign_preview').innerHTML = $('gi_sign_preview').getAttribute('data-default');
$('gi_logo_input').value = ''; $('gi_sign_input').value = '';
renderItems();
$('inv_no').value = 'INV-001';
['inv_date','due_date','s_name','s_gstin','s_addr','s_pin','s_email','s_phone','b_name','b_gstin','b_addr','b_pin','b_email','b_phone','bank_name','bank_acc','bank_ifsc','notes'].forEach(function(id){
var el = $(id); if(el) el.value = '';
});
$('discount').value = 0;
$('igst_toggle').checked = false;
igstMode = false;
$('gst_type_badge').textContent = 'CGST + SGST (Intrastate)';
$('gst_type_badge').className = 'badge badge-green';
$('cgst_row').style.display = 'flex';
$('sgst_row').style.display = 'flex';
$('igst_row').style.display = 'none';
$('gi_save_history_label').textContent = 'Save to History';
setDefaultDates();
try{ localStorage.removeItem(STORAGE_KEY); }catch(e){}
calcTotals();
showToast('Form has been reset');
});
/* ---- local draft autosave ---- */
function saveDraft(){
try{
localStorage.setItem(STORAGE_KEY, JSON.stringify(gatherFormData()));
}catch(e){ /* storage unavailable - ignore silently */ }
}
function loadDraft(){
try{
var raw = localStorage.getItem(STORAGE_KEY);
if(!raw) return false;
applyFormData(JSON.parse(raw));
return true;
}catch(e){ return false; }
}
['inv_no','inv_date','due_date','s_name','s_gstin','s_addr','s_state','s_pin','s_email','s_phone','b_name','b_gstin','b_addr','b_state','b_pin','b_email','b_phone','bank_name','bank_acc','bank_ifsc','pay_terms','notes'].forEach(function(id){
var el = $(id);
if(el) el.addEventListener('change', saveDraft);
});
function setDefaultDates(){
var today = new Date().toISOString().split('T')[0];
$('inv_date').value = today;
var due = new Date(); due.setDate(due.getDate()+30);
$('due_date').value = due.toISOString().split('T')[0];
}
/* ---- init ---- */
var hadDraft = loadDraft();
if(!hadDraft){
setDefaultDates();
addItem(true);
} else if(!$('inv_date').value){
setDefaultDates();
}
calcTotals();
loadHistory();
})();
'+
'
'+
''+escapeHtml(r.invoice_no || 'Untitled Invoice')+'
'+
''+escapeHtml(r.buyer_name || 'No buyer name')+' · '+escapeHtml(dateStr)+'
'+
'₹'+amt.toFixed(2)+'
'+
''+
''+
''+
'
'+
'