Capital Gains Tax Calculator (2024/2025 Estimates)
Including salary, wages, etc. (excluding this gain)
Single
Married Filing Jointly
Head of Household
Long Term (More than 1 year)
Short Term (1 year or less)
Long term assets benefit from lower tax rates.
Total Capital Gain:$0.00
Estimated Federal Tax:$0.00
Net Investment Income Tax (NIIT):$0.00
Net Profit After Tax:$0.00
Understanding Capital Gains Tax
Capital gains tax is the levy applied to the profit realized from the sale of a non-inventory asset, such as stocks, bonds, precious metals, or real estate. The tax is only triggered when the asset is sold, not while it is held.
Short-Term vs. Long-Term Capital Gains
The duration you hold an asset significantly impacts your tax liability:
Short-Term: Assets held for one year or less. These profits are taxed as ordinary income, meaning they are subject to your standard federal income tax bracket (ranging from 10% to 37%).
Long-Term: Assets held for more than one year. These benefit from preferential tax rates of 0%, 15%, or 20%, depending on your filing status and taxable income.
Net Investment Income Tax (NIIT)
High-income earners may be subject to an additional 3.8% Net Investment Income Tax. This applies if your Modified Adjusted Gross Income (MAGI) exceeds certain thresholds ($200,000 for Single filers, $250,000 for Married Filing Jointly).
Strategies to Minimize Liability
Investors often use strategies like Tax-Loss Harvesting (selling losing assets to offset gains) or holding assets for over a year to qualify for long-term rates. For real estate, a 1031 Exchange allows deferring taxes by reinvesting proceeds into a similar property.
2024 Long-Term Capital Gains Tax Brackets (Estimates)
For Single filers:
0% Rate: Income up to $47,025
15% Rate: Income between $47,026 and $518,900
20% Rate: Income over $518,900
Note: This calculator provides estimates for federal taxes only and does not account for state or local taxes, which vary significantly by location.
function calculateCapitalGains() {
// 1. Get Inputs
var buyPrice = parseFloat(document.getElementById('cgtBuyPrice').value);
var sellPrice = parseFloat(document.getElementById('cgtSellPrice').value);
var annualIncome = parseFloat(document.getElementById('cgtIncome').value);
var filingStatus = document.getElementById('cgtFilingStatus').value;
var duration = document.getElementById('cgtDuration').value;
// Validate Inputs
if (isNaN(buyPrice) || isNaN(sellPrice) || isNaN(annualIncome)) {
alert("Please enter valid numbers for prices and income.");
return;
}
// 2. Calculate Gross Gain
var gain = sellPrice – buyPrice;
// Variables for tax calculations
var fedTax = 0;
var niitTax = 0;
var totalIncome = annualIncome + gain;
// 3. Logic Execution
if (gain niitThreshold) {
var excessIncome = totalIncome – niitThreshold;
var taxableNiitAmount = Math.min(gain, excessIncome);
niitTax = taxableNiitAmount * 0.038;
}
if (duration === 'short') {
// Short Term: Taxed at Ordinary Income Rates
// Simplified approach: Calculate marginal impact
// We will estimate effective rate based on simplified 2024 brackets for Single
// Real tax logic requires progressive calculation, here we approximate the tax on the gain portion
// This is a complex calculation usually, we will use a simplified marginal rate lookup
// based on where the income lands.
var marginalRate = 0.22; // default average
// Simplified standard brackets 2024 (Single)
// 10%: 0-11600, 12%: 11600-47150, 22%: 47150-100525, 24%: 100525-191950
// 32%: 191950-243725, 35%: 243725-609350, 37%: > 609350
// We will just apply the rate corresponding to the top of the stack (Income + Gain)
// This is an estimation.
var topStack = annualIncome + gain;
if (filingStatus === 'single') {
if (topStack > 609350) marginalRate = 0.37;
else if (topStack > 243725) marginalRate = 0.35;
else if (topStack > 191950) marginalRate = 0.32;
else if (topStack > 100525) marginalRate = 0.24;
else if (topStack > 47150) marginalRate = 0.22;
else if (topStack > 11600) marginalRate = 0.12;
else marginalRate = 0.10;
} else if (filingStatus === 'married') {
if (topStack > 731200) marginalRate = 0.37;
else if (topStack > 487450) marginalRate = 0.35;
else if (topStack > 383900) marginalRate = 0.32;
else if (topStack > 201050) marginalRate = 0.24;
else if (topStack > 94300) marginalRate = 0.22;
else if (topStack > 23200) marginalRate = 0.12;
else marginalRate = 0.10;
} else {
// Head of household approx
if (topStack > 609350) marginalRate = 0.37;
else if (topStack > 243700) marginalRate = 0.35;
else if (topStack > 191950) marginalRate = 0.32;
else if (topStack > 100500) marginalRate = 0.24;
else if (topStack > 63100) marginalRate = 0.22;
else if (topStack > 16550) marginalRate = 0.12;
else marginalRate = 0.10;
}
fedTax = gain * marginalRate;
} else {
// Long Term: Preferential Rates (0%, 15%, 20%)
// Rates apply to the income "stack"
var rate0Limit, rate15Limit;
if (filingStatus === 'single') {
rate0Limit = 47025;
rate15Limit = 518900;
} else if (filingStatus === 'married') {
rate0Limit = 94050;
rate15Limit = 583750;
} else {
// HoH
rate0Limit = 63000;
rate15Limit = 551350;
}
// Logic to calculate how much of the gain falls into which bucket
// Existing ordinary income fills the buckets first
var incomeFillsUpTo = annualIncome;
var gainRemains = gain;
// Bucket 0%
var spaceIn0 = Math.max(0, rate0Limit – incomeFillsUpTo);
var gainIn0 = Math.min(gainRemains, spaceIn0);
fedTax += gainIn0 * 0;
gainRemains -= gainIn0;
incomeFillsUpTo += gainIn0;
// Bucket 15%
if (gainRemains > 0) {
var spaceIn15 = Math.max(0, rate15Limit – incomeFillsUpTo);
var gainIn15 = Math.min(gainRemains, spaceIn15);
fedTax += gainIn15 * 0.15;
gainRemains -= gainIn15;
incomeFillsUpTo += gainIn15;
}
// Bucket 20%
if (gainRemains > 0) {
fedTax += gainRemains * 0.20;
}
}
}
var totalTax = fedTax + niitTax;
var netProfit = gain – totalTax;
// 4. Update UI
document.getElementById('resTotalGain').innerText = formatMoney(gain);
document.getElementById('resFedTax').innerText = formatMoney(fedTax);
document.getElementById('resNiit').innerText = formatMoney(niitTax);
document.getElementById('resNetProfit').innerText = formatMoney(netProfit);
document.getElementById('cgtResults').style.display = 'block';
}
function formatMoney(amount) {
return '$' + amount.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}