401(k) Calculator Formula
Understand the math behind the 401(k) calculator. Each variable explained with a worked example.
Formulas Used
Projected 401(k) Balance
future_value = current_balance * pow(1 + r, years_to_retire) + total_annual * (pow(1 + r, years_to_retire) - 1) / rTotal Contributions
total_contributions = total_annual * years_to_retireInvestment Growth
total_growth = future_value - current_balance - total_contributionsTotal Employer Match
employer_total = employer_contribution * years_to_retireVariables
| Variable | Description | Default |
|---|---|---|
current_balance | Current Balance(USD) | 50000 |
annual_contribution | Annual Contribution(USD) | 19500 |
employer_match_pct | Employer Match(%) | 50 |
match_limit_pct | Match Limit (% of Salary)(%) | 6 |
salary | Annual Salary(USD) | 85000 |
annual_return | Expected Annual Return(%) | 7 |
years_to_retire | Years Until Retirement(years) | 25 |
r | Derived value= annual_return / 100 | calculated |
employer_contribution | Derived value= salary * match_limit_pct / 100 * employer_match_pct / 100 | calculated |
total_annual | Derived value= annual_contribution + employer_contribution | calculated |
How It Works
How the 401(k) Calculator Works
This calculator projects your retirement savings using compound growth on both your existing balance and future contributions.
Formula
FV = PV × (1 + r)^n + PMT × [(1 + r)^n − 1] / r
Where:
Employer match is calculated as: Salary × Match Limit % × Match Rate %.
Worked Example
$50,000 current balance, $19,500/yr contribution, 50% employer match up to 6% of an $85,000 salary, 7% return, 25 years.
current_balance = 50000annual_contribution = 19500employer_match_pct = 50match_limit_pct = 6salary = 85000annual_return = 7years_to_retire = 25
- 01Employer match = $85,000 × 6% × 50% = $2,550/yr
- 02Total annual = $19,500 + $2,550 = $22,050
- 03Current balance growth = $50,000 × (1.07)^25 = $271,372
- 04Contribution growth = $22,050 × [(1.07)^25 − 1] / 0.07 = $1,393,751
- 05Projected balance = $271,372 + $1,393,751 = $1,665,123
Ready to run the numbers?
Open 401(k) Calculator