Estimate your federal tax liability on asset sales.
Single
Married Filing Jointly
Head of Household
Short Term (Less than 1 year)
Long Term (More than 1 year)
Please enter valid numeric values for all dollar fields.
Estimated Tax Results
Total Capital Gain:$0.00
Tax Rate Applied:0%
Federal Capital Gains Tax:$0.00
Net Investment Income Tax (NIIT):$0.00
Total Estimated Tax Liability:$0.00
Net Profit After Tax:$0.00
Understanding Capital Gains Tax
Capital gains tax is a levy on the profit realized from the sale of a non-inventory asset that was purchased at a lower price. The most common capital gains are realized from the sale of stocks, bonds, precious metals, and property.
Short-Term vs. Long-Term Rates
The duration you hold an asset significantly impacts your tax liability:
Short-Term Capital Gains: Assets held for one year or less. These are taxed as ordinary income, which means they are subject to your standard federal income tax brackets (ranging from 10% to 37% in 2024).
Long-Term Capital Gains: Assets held for more than one year. These benefit from preferential tax rates of 0%, 15%, or 20%, depending on your taxable income and filing status.
2024 Long-Term Capital Gains Brackets
If you hold an asset for more than a year, your tax rate depends on your taxable income:
0% Rate: For single filers with income up to $47,025 (or $94,050 for married filing jointly).
15% Rate: For single filers with income up to $518,900 (or $583,750 for married filing jointly).
20% Rate: For single filers with income above $518,900 (or $583,750 for married filing jointly).
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 $200,000 for single filers or $250,000 for married couples filing jointly. This calculator includes NIIT estimations where applicable.
Disclaimer: This calculator provides estimates based on 2024 federal tax brackets. It does not account for state or local taxes, or specific deductions. Consult a qualified tax professional for your specific situation.
function calculateCapitalGains() {
// Inputs
var purchasePrice = document.getElementById('cgtPurchasePrice').value;
var salePrice = document.getElementById('cgtSalePrice').value;
var annualIncome = document.getElementById('cgtAnnualIncome').value;
var filingStatus = document.getElementById('cgtFilingStatus').value;
var duration = document.getElementById('cgtDuration').value;
// Validation
if (purchasePrice === "" || salePrice === "" || annualIncome === "") {
document.getElementById('cgtError').style.display = 'block';
document.getElementById('cgtResults').style.display = 'none';
return;
}
var buy = parseFloat(purchasePrice);
var sell = parseFloat(salePrice);
var income = parseFloat(annualIncome);
if (isNaN(buy) || isNaN(sell) || isNaN(income)) {
document.getElementById('cgtError').style.display = 'block';
document.getElementById('cgtResults').style.display = 'none';
return;
}
document.getElementById('cgtError').style.display = 'none';
// Core Calculation
var gain = sell – buy;
// Handle Loss
if (gain Threshold, calculate 3.8% on the overlap
var totalIncome = income + gain;
if (totalIncome > niitThreshold) {
var amountSubjectToNiit = Math.min(gain, totalIncome – niitThreshold);
niitTax = amountSubjectToNiit * 0.038;
}
// Tax Bracket Logic
if (duration === 'short') {
// Short Term: Taxed as Ordinary Income
// Simplified 2024 Brackets estimation logic for Single/Joint/Head
// Note: This is a simplified effective rate calculation for the Gain portion specifically,
// assuming it stacks on top of 'annualIncome'.
// To calculate strictly the tax on the gain, we calculate tax(income + gain) – tax(income)
fedTax = calculateOrdinaryTax(income + gain, filingStatus) – calculateOrdinaryTax(income, filingStatus);
// Calculate effective rate on just the gain
var effectiveRate = (fedTax / gain) * 100;
taxRateText = effectiveRate.toFixed(1) + "% (Ordinary Income)";
} else {
// Long Term: 0%, 15%, 20%
// Brackets 2024
var limit0, limit15;
if (filingStatus === 'single') {
limit0 = 47025;
limit15 = 518900;
} else if (filingStatus === 'married_joint') {
limit0 = 94050;
limit15 = 583750;
} else { // Head of household
limit0 = 63000;
limit15 = 551350;
}
// The gain stacks on top of ordinary income
var remainingGain = gain;
var currentIncomeLevel = income;
// Tier 1: 0%
var roomIn0 = Math.max(0, limit0 – currentIncomeLevel);
var taxedAt0 = Math.min(remainingGain, roomIn0);
remainingGain -= taxedAt0;
currentIncomeLevel += taxedAt0;
// Tier 2: 15%
var roomIn15 = Math.max(0, limit15 – currentIncomeLevel);
var taxedAt15 = Math.min(remainingGain, roomIn15);
fedTax += taxedAt15 * 0.15;
remainingGain -= taxedAt15;
currentIncomeLevel += taxedAt15;
// Tier 3: 20%
var taxedAt20 = remainingGain;
fedTax += taxedAt20 * 0.20;
// Determine text label for rate
if (taxedAt20 > 0) taxRateText = "20% (Max Rate)";
else if (taxedAt15 > 0) taxRateText = "15% (Standard Rate)";
else taxRateText = "0% (Exempt)";
// If mixed brackets, show effective
if ((taxedAt0 > 0 && taxedAt15 > 0) || (taxedAt15 > 0 && taxedAt20 > 0)) {
taxRateText = ((fedTax / gain) * 100).toFixed(1) + "% (Blended)";
}
}
displayResults(gain, taxRateText, fedTax, niitTax, fedTax + niitTax);
}
function calculateOrdinaryTax(taxableIncome, status) {
// Simplified 2024 Ordinary Income Tax Brackets (Standard Deduction not applied here as input assumes taxable income)
// Brackets are progressive
var brackets = [];
if (status === 'single') {
brackets = [
{ limit: 11600, rate: 0.10 },
{ limit: 47150, rate: 0.12 },
{ limit: 100525, rate: 0.22 },
{ limit: 191950, rate: 0.24 },
{ limit: 243725, rate: 0.32 },
{ limit: 609350, rate: 0.35 },
{ limit: Infinity, rate: 0.37 }
];
} else if (status === 'married_joint') {
brackets = [
{ limit: 23200, rate: 0.10 },
{ limit: 94300, rate: 0.12 },
{ limit: 201050, rate: 0.22 },
{ limit: 383900, rate: 0.24 },
{ limit: 487450, rate: 0.32 },
{ limit: 731200, rate: 0.35 },
{ limit: Infinity, rate: 0.37 }
];
} else { // Head of Household
brackets = [
{ limit: 16550, rate: 0.10 },
{ limit: 63100, rate: 0.12 },
{ limit: 100500, rate: 0.22 },
{ limit: 191950, rate: 0.24 },
{ limit: 243700, rate: 0.32 },
{ limit: 609350, rate: 0.35 },
{ limit: Infinity, rate: 0.37 }
];
}
var tax = 0;
var previousLimit = 0;
var remainingIncome = taxableIncome;
for (var i = 0; i < brackets.length; i++) {
var bracket = brackets[i];
var range = bracket.limit – previousLimit;
var incomeInBracket = Math.min(remainingIncome, range);
if (incomeInBracket <= 0) break;
tax += incomeInBracket * bracket.rate;
remainingIncome -= incomeInBracket;
previousLimit = bracket.limit;
}
return tax;
}
function displayResults(gain, rateText, fed, niit, total) {
var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2
});
document.getElementById('resTotalGain').innerText = formatter.format(gain);
document.getElementById('resTaxRate').innerText = rateText;
document.getElementById('resFedTax').innerText = formatter.format(fed);
document.getElementById('resNiitTax').innerText = formatter.format(niit);
document.getElementById('resTotalTax').innerText = formatter.format(total);
document.getElementById('resNetProfit').innerText = formatter.format(gain – total);
document.getElementById('cgtResults').style.display = 'block';
}