Capital Gains Tax Calculator (2024/2025 Estimator)
Before you sell an asset, it is crucial to understand the potential tax liability. Whether you are selling stocks, real estate, or cryptocurrency, your profit is subject to capital gains tax. Use this specific calculator to estimate your federal and state tax obligations based on your filing status, income level, and how long you have held the asset.
Calculate Your Tax Liability
Short Term (Less than 1 year)
Long Term (More than 1 year)
Include salary, wages, and other income.
Single
Married Filing Jointly
Head of Household
Please enter valid positive numbers for prices and income.
Total Capital Gain:$0.00
Federal Tax (Estimated):$0.00
State Tax (Estimated):$0.00
Net Investment Income Tax (NIIT):$0.00
After-Tax Profit:$0.00
function calculateCapitalGains() {
// 1. Get Inputs
var purchasePrice = parseFloat(document.getElementById('cgt-purchase-price').value);
var salePrice = parseFloat(document.getElementById('cgt-sale-price').value);
var income = parseFloat(document.getElementById('cgt-income').value);
var duration = document.getElementById('cgt-duration').value;
var status = document.getElementById('cgt-status').value;
var stateRate = parseFloat(document.getElementById('cgt-state-tax').value);
var errorMsg = document.getElementById('cgt-error-msg');
var resultsBox = document.getElementById('cgt-results-box');
// 2. Validation
if (isNaN(purchasePrice) || isNaN(salePrice) || isNaN(income)) {
errorMsg.style.display = 'block';
resultsBox.style.display = 'none';
return;
}
if (isNaN(stateRate)) { stateRate = 0; }
errorMsg.style.display = 'none';
// 3. Calculate Gross Gain
var grossGain = salePrice – purchasePrice;
// Handle Loss
if (grossGain <= 0) {
resultsBox.style.display = 'block';
document.getElementById('cgt-res-gain').innerText = formatMoney(grossGain);
document.getElementById('cgt-res-fed').innerText = "$0.00";
document.getElementById('cgt-res-state').innerText = "$0.00";
document.getElementById('cgt-res-niit').innerText = "$0.00";
document.getElementById('cgt-res-net').innerText = formatMoney(grossGain);
return; // No tax on loss
}
// 4. Determine Federal Tax Rate
var fedTax = 0;
if (duration === 'short') {
// Short Term = Ordinary Income Tax Brackets (Simplified 2024 projections)
// Using marginal rate approach relative to total income
// This is an estimation. In reality, it fills buckets. We will estimate based on the top bracket the income falls into.
// Add gain to income to see top bracket
var totalIncome = income + grossGain;
var rate = 0;
// Simplified Brackets 2024 for Single (Married is wider)
// Note: Real tax calc requires filling buckets. For a calculator tool, we estimate effective tax on the gain.
// We will use the marginal rate of the total income level.
if (status === 'married') {
if (totalIncome <= 23200) rate = 0.10;
else if (totalIncome <= 94300) rate = 0.12;
else if (totalIncome <= 201050) rate = 0.22;
else if (totalIncome <= 383900) rate = 0.24;
else if (totalIncome <= 487450) rate = 0.32;
else if (totalIncome <= 731200) rate = 0.35;
else rate = 0.37;
} else { // Single or Head (Approximated to Single for simplicity in JS block)
if (totalIncome <= 11600) rate = 0.10;
else if (totalIncome <= 47150) rate = 0.12;
else if (totalIncome <= 100525) rate = 0.22;
else if (totalIncome <= 191950) rate = 0.24;
else if (totalIncome <= 243725) rate = 0.32;
else if (totalIncome <= 609350) rate = 0.35;
else rate = 0.37;
}
fedTax = grossGain * rate;
} else {
// Long Term Capital Gains Rates (0%, 15%, 20%)
// Based on 2024 Thresholds
var ltcgRate = 0;
if (status === 'single') {
if (income <= 47025) ltcgRate = 0;
else if (income <= 518900) ltcgRate = 0.15;
else ltcgRate = 0.20;
} else if (status === 'married') {
if (income <= 94050) ltcgRate = 0;
else if (income <= 583750) ltcgRate = 0.15;
else ltcgRate = 0.20;
} else if (status === 'head') {
if (income <= 63000) ltcgRate = 0;
else if (income niitThreshold) {
niitTax = grossGain * 0.038;
}
// 6. State Tax
var stateTaxAmount = grossGain * (stateRate / 100);
// 7. Totals
var totalTax = fedTax + stateTaxAmount + niitTax;
var netProfit = grossGain – totalTax;
// 8. Display
document.getElementById('cgt-res-gain').innerText = formatMoney(grossGain);
document.getElementById('cgt-res-fed').innerText = formatMoney(fedTax);
document.getElementById('cgt-res-state').innerText = formatMoney(stateTaxAmount);
document.getElementById('cgt-res-niit').innerText = formatMoney(niitTax);
document.getElementById('cgt-res-net').innerText = formatMoney(netProfit);
resultsBox.style.display = 'block';
}
function formatMoney(amount) {
return '$' + amount.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
Understanding Capital Gains Tax
Capital gains tax is a levy on the profit realized from the sale of a non-inventory asset. The most common capital gains are realized from the sale of stocks, bonds, precious metals, real estate, and property. The tax is not applied to unsold assets; it only triggers when you sell the asset for a price higher than your original purchase price (known as the cost basis).
Short-Term vs. Long-Term Capital Gains
The duration for which you hold an asset significantly impacts your tax rate:
Short-Term: Assets held for one year or less. These are taxed as ordinary income, meaning they are added to your salary and other earnings and taxed at your regular marginal tax rate (ranging from 10% to 37%).
Long-Term: Assets held for more than one year. These benefit from preferential tax rates, typically 0%, 15%, or 20%, depending on your taxable income.
2024 Long-Term Capital Gains Tax Brackets
For the 2024 tax year, the income thresholds for long-term capital gains rates are as follows:
Tax Rate
Single Filers
Married Filing Jointly
Head of Household
0%
Up to $47,025
Up to $94,050
Up to $63,000
15%
$47,026 – $518,900
$94,051 – $583,750
$63,001 – $551,350
20%
Over $518,900
Over $583,750
Over $551,350
What is the Net Investment Income Tax (NIIT)?
High-income earners may be subject to an additional 3.8% tax known as the Net Investment Income Tax (NIIT). This applies if your Modified Adjusted Gross Income (MAGI) exceeds:
$200,000 for Single or Head of Household filers
$250,000 for Married Filing Jointly
This calculator automatically checks if your income exceeds these thresholds and applies the NIIT to your gain estimation.
How to Reduce Capital Gains Tax
There are several strategies investors use to minimize their tax liability:
Hold for over a year: Waiting until the 1-year mark passes converts the gain from short-term to long-term, significantly reducing the tax rate.
Tax-Loss Harvesting: You can offset capital gains with capital losses. If you sell another asset at a loss, that loss can reduce your taxable gains dollar-for-dollar.
Use Tax-Advantaged Accounts: Trading within a 401(k) or IRA does not trigger immediate capital gains taxes.
Disclaimer: This calculator is for educational and estimation purposes only. Tax laws are complex and subject to change. Please consult a qualified CPA or tax professional for advice specific to your financial situation.