Estimate your 2024 tax liability on investment sales
Include salary, wages, etc.
Single
Married Filing Jointly
Head of Household
Short Term (Less than 1 year)
Long Term (More than 1 year)
Please enter valid positive numbers for prices and income.
Total Capital Gain
$0
Sale Price – Purchase Price
Estimated Tax Owed
$0
Includes NIIT if applicable
Net Profit After Tax
$0
Effective Tax Rate: 0%
Understanding Capital Gains Tax in 2024
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.
Short-Term vs. Long-Term Capital Gains
The duration you hold an asset significantly impacts your tax liability:
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 federal income tax bracket, which can range from 10% to 37%.
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 determined by your taxable income:
Rate
Single Filers
Married Filing Jointly
0%
Up to $47,025
Up to $94,050
15%
$47,026 – $518,900
$94,051 – $583,750
20%
Over $518,900
Over $583,750
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
$250,000 for Married Filing Jointly
This calculator includes NIIT in its estimates where applicable.
function calculateCGT() {
// Inputs
var buyPrice = parseFloat(document.getElementById('purchasePrice').value);
var sellPrice = parseFloat(document.getElementById('salePrice').value);
var income = parseFloat(document.getElementById('annualIncome').value);
var status = document.getElementById('filingStatus').value;
var duration = document.getElementById('ownershipDuration').value;
var errorDiv = document.getElementById('errorMsg');
var resultDiv = document.getElementById('resultSection');
// Validation
if (isNaN(buyPrice) || isNaN(sellPrice) || isNaN(income) || buyPrice < 0 || sellPrice < 0 || income < 0) {
errorDiv.style.display = 'block';
resultDiv.style.display = 'none';
return;
}
errorDiv.style.display = 'none';
// Core Calculation
var gain = sellPrice – buyPrice;
// If loss, no tax
if (gain <= 0) {
document.getElementById('displayGain').innerText = formatCurrency(gain);
document.getElementById('displayTax').innerText = "$0.00";
document.getElementById('displayNet').innerText = formatCurrency(gain); // Net loss is just the loss
document.getElementById('displayRate').innerText = "No tax on capital losses";
resultDiv.style.display = 'block';
return;
}
var taxAmount = 0;
var taxRate = 0;
var niitAmount = 0;
// Determine Tax Logic based on Duration
if (duration === 'short') {
// Short Term = Ordinary Income Tax Brackets (2024 Simplified for estimation)
// We use the marginal rate of the total income (Income + Gain)
var totalIncome = income + gain;
taxRate = getOrdinaryIncomeRate(totalIncome, status);
taxAmount = gain * taxRate;
} else {
// Long Term = Preferential Rates (0%, 15%, 20%)
// Rate is determined by taxable income (usually just income, sometimes income + gain determines the bracket push)
// For simplicity in this tool, we look up the rate based on current taxable income + gain to be safe,
// though strictly speaking, it stacks.
var totalForBracket = income + gain;
// 2024 Long Term Capital Gains Brackets
// Single: 0% up to 47025, 15% up to 518900, 20% over
// Married: 0% up to 94050, 15% up to 583750, 20% over
// Head: 0% up to 63000, 15% up to 551350, 20% over (Approx for Head)
if (status === 'married') {
if (totalForBracket <= 94050) { taxRate = 0; }
else if (totalForBracket <= 583750) { taxRate = 0.15; }
else { taxRate = 0.20; }
} else if (status === 'head') {
if (totalForBracket <= 63000) { taxRate = 0; }
else if (totalForBracket <= 551350) { taxRate = 0.15; }
else { taxRate = 0.20; }
} else { // Single
if (totalForBracket <= 47025) { taxRate = 0; }
else if (totalForBracket niitThreshold) {
// NIIT applies to the lesser of: Net Investment Income (the Gain) OR Excess over threshold
var excess = magi – niitThreshold;
var subjectToNiit = Math.min(gain, excess);
niitAmount = subjectToNiit * 0.038;
}
var totalTax = taxAmount + niitAmount;
var netProfit = gain – totalTax;
var effectiveRate = (gain > 0) ? (totalTax / gain) * 100 : 0;
// Output Results
document.getElementById('displayGain').innerText = formatCurrency(gain);
document.getElementById('displayTax').innerText = formatCurrency(totalTax);
document.getElementById('displayNet').innerText = formatCurrency(netProfit);
document.getElementById('displayRate').innerText = "Effective Tax Rate: " + effectiveRate.toFixed(2) + "% " + (niitAmount > 0 ? "(Inc. NIIT)" : "");
resultDiv.style.display = 'block';
}
function getOrdinaryIncomeRate(income, status) {
// 2024 Tax Brackets (Simplified marginal rate return)
// Returns the top marginal rate
if (status === 'married') {
if (income <= 23200) return 0.10;
if (income <= 94300) return 0.12;
if (income <= 201050) return 0.22;
if (income <= 383900) return 0.24;
if (income <= 487450) return 0.32;
if (income <= 731200) return 0.35;
return 0.37;
} else {
// Single & Head (Head is slightly different but using Single for estimation usually acceptable in simplified tools, adjusted slightly)
// Using Single brackets for non-married
if (income <= 11600) return 0.10;
if (income <= 47150) return 0.12;
if (income <= 100525) return 0.22;
if (income <= 191950) return 0.24;
if (income <= 243725) return 0.32;
if (income <= 609350) return 0.35;
return 0.37;
}
}
function formatCurrency(num) {
return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(num);
}