A curated, copy-paste-ready collection of India-specific financial calculation formulas in JavaScript. All formulas are validated and used in production at StockCalc.in — India’s most comprehensive free financial calculator platform.
MIT Licensed. No dependencies. Browser + Node.js compatible.
| Formula | Section |
|---|---|
| FD Maturity | → |
| PPF Maturity | → |
| CAGR | → |
| Gratuity | → |
| GST Inclusive / Exclusive | → |
| LTCG Tax | → |
| Rule of 72 | → |
| Inflation-Adjusted Returns | → |
| NPS Corpus | → |
/**
* FD Maturity Amount
* @param {number} principal - Deposit amount (₹)
* @param {number} rate - Annual interest rate (%)
* @param {number} years - Tenure (years)
* @param {number} frequency - Compounding: 1=annual, 2=half-yearly, 4=quarterly, 12=monthly
*/
function fdMaturity(principal, rate, years, frequency = 4) {
return principal * Math.pow(1 + rate / 100 / frequency, frequency * years);
}
// Examples:
fdMaturity(100000, 7.1, 1, 4); // SBI FD ₹1L, 1yr, quarterly → ₹1,07,262
fdMaturity(100000, 7.25, 5, 4); // HDFC FD ₹1L, 5yr → ₹1,42,814
// → Live calculator: https://stockcalc.in/calculator/fd
/**
* PPF Maturity after 15 years
* Interest credited annually on minimum balance between 5th–last of month
* @param {number} annual - Annual deposit (₹) — max ₹1,50,000
* @param {number} rate - Current PPF rate (%) — 7.1% as of 2026
*/
function ppfMaturity(annual, rate = 7.1) {
let balance = 0;
for (let year = 1; year <= 15; year++) {
balance = (balance + annual) * (1 + rate / 100);
}
return Math.round(balance);
}
ppfMaturity(150000, 7.1); // ₹40,68,209 at max contribution
// → Live calculator: https://stockcalc.in/calculator/ppf
/**
* CAGR — Compound Annual Growth Rate
* @param {number} beginValue - Initial value / investment
* @param {number} endValue - Final value / current value
* @param {number} years - Number of years
* @returns {number} - CAGR in % (e.g. 12.5 for 12.5%)
*/
function cagr(beginValue, endValue, years) {
return (Math.pow(endValue / beginValue, 1 / years) - 1) * 100;
}
cagr(100000, 250000, 7); // → 13.98% CAGR
// → Live calculator: https://stockcalc.in/calculator/cagr
/**
* Gratuity as per Payment of Gratuity Act, 1972
* Applicable for employees with 5+ years of continuous service
* @param {number} lastSalary - Last drawn Basic + DA (₹/month)
* @param {number} years - Years of service
*/
function gratuity(lastSalary, years) {
// Formula: (15/26) × Last Salary × Years
// 15 days wages per year, 26 working days/month
return Math.round((15 / 26) * lastSalary * years);
}
gratuity(80000, 10); // → ₹4,61,538
// → Live calculator: https://stockcalc.in/calculator/gratuity
/**
* GST — Add GST to a base price (exclusive → inclusive)
* @param {number} amount - Pre-GST price
* @param {number} gstRate - GST rate % (5, 12, 18, or 28)
*/
function addGST(amount, gstRate) {
const gst = amount * gstRate / 100;
return { baseAmount: amount, gst, totalAmount: amount + gst };
}
/**
* Extract GST from GST-inclusive price (inclusive → exclusive)
* @param {number} totalAmount - Price including GST
* @param {number} gstRate - GST rate %
*/
function removeGST(totalAmount, gstRate) {
const baseAmount = totalAmount * 100 / (100 + gstRate);
const gst = totalAmount - baseAmount;
return { baseAmount: Math.round(baseAmount), gst: Math.round(gst), totalAmount };
}
addGST(1000, 18); // { baseAmount: 1000, gst: 180, totalAmount: 1180 }
removeGST(1180, 18); // { baseAmount: 1000, gst: 180, totalAmount: 1180 }
// → Live calculator: https://stockcalc.in/calculator/gst
/**
* LTCG Tax on Indian Equity (post-Budget 2024)
* Rate: 12.5% on gains above ₹1.25L (no indexation for equity)
* @param {number} purchasePrice - Cost of acquisition (₹)
* @param {number} salePrice - Sale price (₹)
* @param {number} units - Number of units / shares
*/
function ltcgTax(purchasePrice, salePrice, units) {
const totalGain = (salePrice - purchasePrice) * units;
const exemptionLimit = 125000; // ₹1.25L exempt per financial year
const taxableGain = Math.max(0, totalGain - exemptionLimit);
const tax = taxableGain * 0.125; // 12.5% flat
const cess = tax * 0.04; // 4% Health & Education Cess
return {
totalGain: Math.round(totalGain),
taxableGain: Math.round(taxableGain),
tax: Math.round(tax + cess),
};
}
ltcgTax(500, 1200, 1000); // Bought 1000 shares at ₹500, sold at ₹1200
// { totalGain: 700000, taxableGain: 575000, tax: 74750 }
// → Live calculator: https://stockcalc.in/calculator/ltcg
/**
* Rule of 72 — How many years to double your money
* @param {number} rate - Annual return rate (%)
* @returns {number} - Approximate years to double
*/
const ruleOf72 = (rate) => 72 / rate;
ruleOf72(12); // → 6 years at 12% return
ruleOf72(7.1); // → ~10.1 years at PPF rate
// → Live calculator: https://stockcalc.in/calculator/rule-of-72
/**
* Real Return after adjusting for inflation
* @param {number} nominalReturn - Expected return (%)
* @param {number} inflationRate - CPI inflation rate (%)
*/
function realReturn(nominalReturn, inflationRate) {
return ((1 + nominalReturn / 100) / (1 + inflationRate / 100) - 1) * 100;
}
realReturn(12, 6); // → 5.66% real return on equity at 6% inflation
// → Live inflation calculator: https://stockcalc.in/calculator/inflation
/**
* NPS Corpus at retirement
* @param {number} monthly - Monthly contribution (₹)
* @param {number} annualRate - Expected annual return (%)
* @param {number} years - Years to retirement
* @param {number} annuityPct - % of corpus used for annuity (min 40%)
* @param {number} annuityRate - Annuity rate (%) — typically 6%
*/
function npsProjection(monthly, annualRate, years, annuityPct = 0.4, annuityRate = 6) {
const r = annualRate / 12 / 100;
const n = years * 12;
const corpus = monthly * (((Math.pow(1 + r, n) - 1) / r) * (1 + r));
const annuityCorpus = corpus * annuityPct;
const lumpsum = corpus * (1 - annuityPct);
const monthlyPension = (annuityCorpus * annuityRate / 100) / 12;
return {
corpus: Math.round(corpus),
lumpsum: Math.round(lumpsum),
monthlyPension: Math.round(monthlyPension),
};
}
npsProjection(10000, 10, 30); // ₹10K/month, 10% return, 30 years
// { corpus: 22,792,459, lumpsum: 13,675,476, monthlyPension: 45,585 }
// → Live calculator: https://stockcalc.in/calculator/nps
| ← All Calculators | Visit StockCalc.in → | Full Calculator List → |