@toolsnap/compound-interest-calculator
v1.0.1
Published
Free online Compound Interest Calculator. Calculate compound interest with different compounding frequencies, contributions, and inflation adjustment.
Maintainers
Readme
@toolsnap/compound-interest-calculator
A lightweight, zero-dependency JavaScript library for calculating compound interest, monthly contribution growth, and effective annual rates.
Features
- 📈 Compound interest calculation with configurable frequency (annual, quarterly, monthly, daily)
- 💰 Monthly contribution support (annuity formula)
- 📊 Year-by-year growth schedule
- 🔢 Effective annual rate (EAR) computation
- 🪶 Zero dependencies
- ✅ Full input validation
Installation
npm install @toolsnap/compound-interest-calculatorUsage
Basic Compound Interest
const { compoundInterest } = require('@toolsnap/compound-interest-calculator');
const result = compoundInterest(10000, 0.06, 10, 12);
// {
// principal: 10000,
// totalInterest: 8193.97,
// totalValue: 18193.97,
// effectiveRate: 6.1678
// }With Monthly Contributions
const { withMonthlyContribution } = require('@toolsnap/compound-interest-calculator');
const result = withMonthlyContribution(5000, 200, 0.07, 20);
// {
// principal: 5000,
// totalContributions: 53000,
// totalInterest: 34664.42,
// totalValue: 87664.42
// }Effective Annual Rate
const { effectiveAnnualRate } = require('@toolsnap/compound-interest-calculator');
const ear = effectiveAnnualRate(0.05, 12);
// 0.05116... (~5.12%)Year-by-Year Growth Schedule
const { growthSchedule } = require('@toolsnap/compound-interest-calculator');
const schedule = growthSchedule(10000, 500, 0.06, 5);
// [
// { year: 1, deposit: 6000, interest: 648.42, balance: 16648.42 },
// { year: 2, deposit: 6000, interest: 1030.56, balance: 23678.98 },
// ...
// ]API
compoundInterest(principal, rate, time, frequency)
Calculate compound interest on a principal amount.
| Parameter | Type | Description |
|-------------|--------|------------------------------------------------|
| principal | number | Initial investment amount |
| rate | number | Annual interest rate (decimal, e.g. 0.05) |
| time | number | Time period in years |
| frequency | number | Compounding frequency/year (default: 12) |
withMonthlyContribution(principal, monthly, rate, years)
Calculate growth with regular monthly contributions using the annuity formula.
effectiveAnnualRate(nominalRate, frequency)
Convert a nominal rate to the effective annual rate (EAR).
growthSchedule(principal, monthly, rate, years)
Generate a year-by-year breakdown of deposits, interest earned, and balance.
Online Calculator
For a full-featured interactive calculator, visit:
👉 Compound Interest Calculator
Related tools:
License
MIT © ToolSnap
