As indie hackers and developers, projecting our long-term investments and personal finance is just as important as writing code. I wanted a fast, ad-free tool for this, so I built a Compound Interest Calculator.
The Approach
I built this using 100% Vanilla JS. No server calls, no tracking scripts. Financial inputs are private and should stay strictly on the client side.
Here is a look at the core function implementing the compound interest formula:
function calculateCompoundInterest(principal, rate, years, compoundingFrequency) {
const r = rate / 100;
const n = compoundingFrequency;
const t = years;
const amount = principal * Math.pow((1 + (r / n)), (n * t));
const interestEarned = amount - principal;
return {
totalAmount: amount.toFixed(2),
totalInterest: interestEarned.toFixed(2)
};
}
Try it out
You can use the live tool for free here: Compound Interest Calculator
Let me know what you think or if you'd add any specific financial metrics in the comments!
Top comments (0)