Calculate your estimated short-term or long-term capital gains tax liability based on your filing status and income.
Short Term (1 year or less)
Long Term (More than 1 year)
Single
Married Filing Jointly
Head of Household
Please enter valid numeric values for prices and income.
Total Capital Gain:$0.00
Tax Type:Long Term
Estimated Tax Rate:0%
Estimated Tax Owed:$0.00
Net Profit (After Tax):$0.00
Understanding Capital Gains Tax
Capital gains tax is a levy assessed on the positive difference between the sale price of the asset and its original purchase price. This calculator helps investors estimate potential tax liabilities when selling assets such as stocks, real estate, or cryptocurrencies in the United States.
Short-term vs. Long-term Capital Gains
The duration you hold an asset significantly impacts your tax rate:
Short-term Capital Gains: Applies to assets held for one year or less. These are taxed as ordinary income, meaning they are subject to your standard federal income tax brackets (ranging from 10% to 37% in 2024).
Long-term Capital Gains: Applies to 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 Tax Brackets
For the 2024 tax year, the long-term capital gains tax rates are broken down as follows:
Single Filers
0% Rate: Taxable income up to $47,025
15% Rate: Taxable income between $47,026 and $518,900
20% Rate: Taxable income over $518,900
Married Filing Jointly
0% Rate: Taxable income up to $94,050
15% Rate: Taxable income between $94,051 and $583,750
20% Rate: Taxable income over $583,750
How This Calculator Works
This tool calculates your "Basis" (Purchase Price) and your "Proceeds" (Sale Price) to determine your gross gain. It then analyzes your annual income and filing status to determine which tax bracket your gain falls into. Note that this is a simplified estimation tool; the Net Investment Income Tax (NIIT) of 3.8% may apply to high-income earners, and state taxes may also apply depending on your location.
Strategies to Minimize Capital Gains Tax
Investors often use strategies like Tax-Loss Harvesting (selling losing investments to offset gains) or holding assets for over a year to qualify for the lower long-term rates. Consult with a CPA or tax professional for advice tailored to your specific financial situation.
function calculateCapitalGainsTax() {
// 1. Get Input Values
var buyPrice = parseFloat(document.getElementById("cgtPurchasePrice").value);
var sellPrice = parseFloat(document.getElementById("cgtSalePrice").value);
var period = document.getElementById("cgtHoldingPeriod").value;
var status = document.getElementById("cgtFilingStatus").value;
var income = parseFloat(document.getElementById("cgtAnnualIncome").value);
// 2. Validation
var errorMsg = document.getElementById("cgtErrorMessage");
var resultBox = document.getElementById("cgt-result");
if (isNaN(buyPrice) || isNaN(sellPrice) || isNaN(income)) {
errorMsg.style.display = "block";
resultBox.style.display = "none";
return;
}
errorMsg.style.display = "none";
// 3. Calculate Gross Gain
var gain = sellPrice – buyPrice;
// Handle Loss or No Gain
if (gain <= 0) {
resultBox.style.display = "block";
document.getElementById("resGain").innerHTML = formatCurrency(gain);
document.getElementById("resGain").style.color = "#e74c3c";
document.getElementById("resType").innerHTML = "Loss/Break-even";
document.getElementById("resRate").innerHTML = "0%";
document.getElementById("resTax").innerHTML = "$0.00";
document.getElementById("resNet").innerHTML = formatCurrency(gain); // Net is just the loss
return;
}
document.getElementById("resGain").style.color = "#2c3e50";
// 4. Calculate Tax
var taxAmount = 0;
var taxRateDisplay = "";
if (period === "short") {
// Short Term: Taxed as Ordinary Income
// Simplified estimation using 2024 brackets roughly
// To do this accurately, we add gain to income and calculate marginal impact,
// but for a calculator of this scope, we will use the marginal rate of the total income (Income + Gain).
var totalIncome = income + gain;
var marginalRate = getOrdinaryTaxRate(totalIncome, status);
taxAmount = gain * marginalRate;
taxRateDisplay = (marginalRate * 100).toFixed(1) + "% (Ordinary Income)";
} else {
// Long Term: Preferential Rates (0%, 15%, 20%)
// The tax rate depends on where the income falls.
// We need to see how much of the gain sits in which bracket.
// Current Taxable Income fills up the lower buckets first.
taxAmount = calculateLongTermTax(income, gain, status);
// Calculate effective rate for display
var effectiveRate = (taxAmount / gain) * 100;
taxRateDisplay = effectiveRate.toFixed(1) + "% (Long Term)";
}
// 5. Net Profit
var netProfit = gain – taxAmount;
// 6. Display Results
document.getElementById("resGain").innerHTML = formatCurrency(gain);
document.getElementById("resType").innerHTML = (period === "short") ? "Short Term" : "Long Term";
document.getElementById("resRate").innerHTML = taxRateDisplay;
document.getElementById("resTax").innerHTML = formatCurrency(taxAmount);
document.getElementById("resNet").innerHTML = formatCurrency(netProfit);
resultBox.style.display = "block";
}
// Helper: Format Currency
function formatCurrency(num) {
return "$" + num.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
// Helper: Get Marginal Ordinary Income Rate (2024 Estimate)
function getOrdinaryTaxRate(totalIncome, status) {
// Simplified brackets logic for 2024
// Returns decimal rate (e.g. 0.22 for 22%)
if (status === "single") {
if (totalIncome <= 11600) return 0.10;
if (totalIncome <= 47150) return 0.12;
if (totalIncome <= 100525) return 0.22;
if (totalIncome <= 191950) return 0.24;
if (totalIncome <= 243725) return 0.32;
if (totalIncome <= 609350) return 0.35;
return 0.37;
} else if (status === "joint") {
if (totalIncome <= 23200) return 0.10;
if (totalIncome <= 94300) return 0.12;
if (totalIncome <= 201050) return 0.22;
if (totalIncome <= 383900) return 0.24;
if (totalIncome <= 487450) return 0.32;
if (totalIncome <= 731200) return 0.35;
return 0.37;
} else if (status === "head") {
if (totalIncome <= 16550) return 0.10;
if (totalIncome <= 63100) return 0.12;
if (totalIncome <= 100500) return 0.22;
if (totalIncome <= 191950) return 0.24;
if (totalIncome <= 243700) return 0.32;
if (totalIncome <= 609350) return 0.35;
return 0.37;
}
return 0.22; // Fallback
}
// Helper: Calculate Long Term Tax Logic
function calculateLongTermTax(currentIncome, gainAmount, status) {
// 2024 Long Term Capital Gains Brackets
var limit0, limit15;
if (status === "single") {
limit0 = 47025;
limit15 = 518900;
} else if (status === "joint") {
limit0 = 94050;
limit15 = 583750;
} else { // Head
limit0 = 63000;
limit15 = 551350;
}
var tax = 0;
var incomeProcessed = currentIncome;
var gainRemaining = gainAmount;
// 0% Bucket
if (incomeProcessed 0 && incomeProcessed 0) {
tax += gainRemaining * 0.20;
}
return tax;
}