GST Invoice Generator

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.
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
Discount- ₹
Grand Total₹0.00
Bank Details & Notes
Grand Total ₹0.00

Fill in the Invoice Form, then click "Generate Preview"

'); w.document.close(); }); /* ---- PDF download ---- */ $('gi_pdf').addEventListener('click', function(){ var area = $('preview_area'); if(area.querySelector('.empty-state')){ showToast('Click "Generate Preview" first'); return; } var btn = $('gi_pdf'); var label = $('gi_pdf_label'); var oldLabel = label.textContent; btn.disabled = true; label.textContent = 'Generating...'; var spin = document.createElement('span'); spin.className = 'spinner'; btn.insertBefore(spin, btn.firstChild); setTimeout(function(){ if(typeof html2canvas === 'undefined' || typeof window.jspdf === 'undefined'){ showToast('PDF library failed to load — check your internet connection'); btn.disabled = false; label.textContent = oldLabel; spin.remove(); return; } html2canvas(area, {scale:2, backgroundColor:'#ffffff', useCORS:true}).then(function(canvas){ var imgData = canvas.toDataURL('image/png'); var jsPDF = window.jspdf.jsPDF; var pdf = new jsPDF('p','mm','a4'); var pageWidth = 210, pageHeight = 297; var imgWidth = pageWidth; var imgHeight = canvas.height * imgWidth / canvas.width; var heightLeft = imgHeight; var position = 0; pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight); heightLeft -= pageHeight; while(heightLeft > 0){ position -= pageHeight; pdf.addPage(); pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight); heightLeft -= pageHeight; } var fname = 'Invoice-' + (v('inv_no') || 'INV-001').replace(/[^a-zA-Z0-9-_]/g,'') + '.pdf'; pdf.save(fname); showToast('PDF downloaded successfully'); btn.disabled = false; label.textContent = oldLabel; spin.remove(); }).catch(function(){ showToast('Something went wrong while creating the PDF'); btn.disabled = false; label.textContent = oldLabel; spin.remove(); }); }, 50); }); /* ================================================================ */ /* HISTORY (stored in this browser via localStorage) */ /* ================================================================ */ function readHistory(){ try{ var raw = localStorage.getItem(HISTORY_KEY); return raw ? JSON.parse(raw) : []; }catch(e){ return []; } } function writeHistory(list){ try{ localStorage.setItem(HISTORY_KEY, JSON.stringify(list)); return true; }catch(e){ showToast('Could not save — your browser storage may be full'); return false; } } $('gi_save_history').addEventListener('click', function(){ if(root.querySelector('#preview_area .empty-state')){ showToast('Click "Generate Preview" first'); return; } if(!v('s_name').trim() || !v('b_name').trim()){ showToast('Please fill in the Seller and Buyer name'); return; } var btn = $('gi_save_history'); var label = $('gi_save_history_label'); var isUpdate = !!currentHistoryId; label.textContent = isUpdate ? 'Updating...' : 'Saving...'; var spin = document.createElement('span'); spin.className = 'spinner'; btn.insertBefore(spin, btn.firstChild); btn.disabled = true; setTimeout(function(){ var list = readHistory(); var now = new Date().toISOString(); var record = { id: currentHistoryId || ('inv_' + Date.now() + '_' + Math.random().toString(36).slice(2,8)), invoice_no: v('inv_no'), buyer_name: v('b_name'), invoice_date: v('inv_date'), grand_total: lastGrandTotal, updated_at: now, data: gatherFormData() }; if(isUpdate){ var idx = list.findIndex(function(r){ return r.id === currentHistoryId; }); if(idx > -1){ list[idx] = record; } else { list.unshift(record); } } else { list.unshift(record); currentHistoryId = record.id; } var ok = writeHistory(list); btn.disabled = false; spin.remove(); if(ok){ showToast(isUpdate ? 'Invoice updated in History' : 'Invoice saved to History'); label.textContent = 'Update in History'; } else { label.textContent = isUpdate ? 'Update in History' : 'Save to History'; } }, 200); }); function renderHistorySkeletonless(){} function loadHistory(search){ var list = readHistory(); if(search){ var q = search.toLowerCase(); list = list.filter(function(r){ return (r.invoice_no||'').toLowerCase().indexOf(q) > -1 || (r.buyer_name||'').toLowerCase().indexOf(q) > -1; }); } list.sort(function(a,b){ return new Date(b.updated_at) - new Date(a.updated_at); }); renderHistoryList(list); var countPill = $('gip_history_count'); var fullCount = readHistory().length; if(fullCount){ countPill.style.display = 'inline-flex'; countPill.textContent = fullCount; } else { countPill.style.display = 'none'; } } function renderHistoryList(rows){ var list = $('gip_history_list'); if(!rows.length){ list.innerHTML = '
'+ ''+ '

No saved invoices yet. Generate a preview and click "Save to History" to see it here.

'+ '
'; 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 '
'+ '
'+ '
'+ '
'+escapeHtml(r.invoice_no || 'Untitled Invoice')+'
'+ '
'+escapeHtml(r.buyer_name || 'No buyer name')+' · '+escapeHtml(dateStr)+'
'+ '
'+ '
₹'+amt.toFixed(2)+'
'+ '
'+ ''+ ''+ '
'+ '
'; }).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(); })();

Free GST Invoice Generator – Create GST-Compliant e Invoices Online with Ease -Vyapar Business

Scroll to Top