Please check your inputs. Sale price and Purchase price are required.
Original cost basis of the asset.
Total amount received from sale.
More than 1 year (Long-Term)
1 year or less (Short-Term)
Determines tax rate type.
Single
Married Filing Jointly
Head of Household
Your income excluding this gain.
Enter 0 if no state capital gains tax.
Estimated Tax Breakdown
Total Capital Gain:$0.00
Federal Tax (Long-Term):$0.00
Net Investment Income Tax (NIIT):$0.00
State Tax:$0.00
Total Estimated Tax:$0.00
Net Profit (After Tax):$0.00
Effective Tax Rate:0.00%
Understanding Capital Gains Tax in 2024 and 2025
Calculating your capital gains tax liability is a crucial step in financial planning, whether you are selling stocks, real estate, or cryptocurrency. The amount you owe depends heavily on how long you held the asset and your overall annual income.
Short-Term vs. Long-Term Capital Gains
The IRS categorizes capital gains based on the holding period of the asset:
Short-Term Capital Gains: 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%).
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.
Federal Long-Term Capital Gains Tax Brackets (2024)
For the 2024 tax year (taxes filed in 2025), the long-term rates generally apply as follows based on taxable income:
0% Rate: Single filers earning up to $47,025; Married filing jointly up to $94,050.
15% Rate: Single filers earning between $47,026 and $518,900; Married filing jointly between $94,051 and $583,750.
20% Rate: Income exceeding the limits above.
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
$125,000 for Married Filing Separately
This calculator automatically checks if your combined income and gains exceed these thresholds and applies the tax to the applicable portion of your investment income.
How to Minimize Capital Gains Tax
There are several strategies investors use to reduce their tax burden:
Hold for over a year: Waiting until the 1-year mark passes can significantly reduce your rate from ordinary income levels (up to 37%) to the long-term rate (max 20%).
Tax-Loss Harvesting: You can offset capital gains by selling underperforming assets at a loss. Up to $3,000 of excess loss can be deducted from ordinary income annually.
Use Tax-Advantaged Accounts: Trading within a 401(k) or IRA defers taxes until withdrawal (or eliminates them in a Roth IRA).
function calculateCapitalGains() {
// 1. Get Inputs
var purchasePrice = parseFloat(document.getElementById('cgt-purchase-price').value);
var salePrice = parseFloat(document.getElementById('cgt-sale-price').value);
var duration = document.getElementById('cgt-duration').value;
var filingStatus = document.getElementById('cgt-filing-status').value;
var annualIncome = parseFloat(document.getElementById('cgt-income').value);
var stateRate = parseFloat(document.getElementById('cgt-state-rate').value);
// 2. Validation
var errorDiv = document.getElementById('cgt-error-msg');
if (isNaN(purchasePrice) || isNaN(salePrice)) {
errorDiv.style.display = 'block';
document.getElementById('cgt-results').style.display = 'none';
return;
}
errorDiv.style.display = 'none';
// Handle defaults if empty
if (isNaN(annualIncome)) annualIncome = 0;
if (isNaN(stateRate)) stateRate = 0;
// 3. Basic Calculations
var capitalGain = salePrice – purchasePrice;
var fedTax = 0;
var niitTax = 0;
var stateTaxAmt = 0;
// Display Logic for Loss
if (capitalGain <= 0) {
document.getElementById('res-total-gain').innerHTML = formatMoney(capitalGain);
document.getElementById('res-fed-type').innerText = "None (Loss)";
document.getElementById('res-fed-tax').innerText = "$0.00";
document.getElementById('res-niit-tax').innerText = "$0.00";
document.getElementById('res-state-tax').innerText = "$0.00";
document.getElementById('res-total-tax').innerText = "$0.00";
document.getElementById('res-net-profit').innerText = formatMoney(capitalGain);
document.getElementById('res-effective-rate').innerText = "0.00%";
document.getElementById('cgt-results').style.display = 'block';
return;
}
// 4. Calculate Federal Tax
// Tax Brackets Configuration (2024 Estimates)
// Long Term Brackets
var lt_0_limit, lt_15_limit;
// Short Term (Ordinary) Brackets (Simplified 2024)
// 10, 12, 22, 24, 32, 35, 37
// Using simple progressive logic function below
// NIIT Thresholds
var niitThreshold;
if (filingStatus === 'single') {
lt_0_limit = 47025;
lt_15_limit = 518900;
niitThreshold = 200000;
} else if (filingStatus === 'married_joint') {
lt_0_limit = 94050;
lt_15_limit = 583750;
niitThreshold = 250000;
} else { // Head of Household
lt_0_limit = 63000;
lt_15_limit = 551350;
niitThreshold = 200000;
}
if (duration === 'long') {
// LONG TERM LOGIC (Stacking Gain on top of Income)
document.getElementById('res-fed-type').innerText = "Long-Term";
var incomeStart = annualIncome;
var incomeEnd = annualIncome + capitalGain;
// Calculate amount in 0% bucket
var amountIn0 = 0;
if (incomeStart 0) {
// The starting point for this chunk is max(incomeStart, lt_0_limit)
var currentStackHeight = Math.max(incomeStart, lt_0_limit);
if (currentStackHeight niitThreshold) {
var excess = totalMAGI – niitThreshold;
var taxableNIIT = Math.min(capitalGain, excess);
niitTax = taxableNIIT * 0.038;
}
// 6. State Tax Calculation
stateTaxAmt = capitalGain * (stateRate / 100);
// 7. Totals
var totalTax = fedTax + niitTax + stateTaxAmt;
var netProfit = capitalGain – totalTax;
var effectiveRate = (totalTax / capitalGain) * 100;
// 8. Update UI
document.getElementById('res-total-gain').innerHTML = formatMoney(capitalGain);
document.getElementById('res-fed-tax').innerHTML = formatMoney(fedTax);
document.getElementById('res-niit-tax').innerHTML = formatMoney(niitTax);
document.getElementById('res-state-tax').innerHTML = formatMoney(stateTaxAmt);
document.getElementById('res-total-tax').innerHTML = formatMoney(totalTax);
document.getElementById('res-net-profit').innerHTML = formatMoney(netProfit);
document.getElementById('res-effective-rate').innerHTML = effectiveRate.toFixed(2) + "%";
document.getElementById('cgt-results').style.display = 'block';
}
function calculateOrdinaryTax(income, status) {
// 2024 Standard Tax Brackets
// Returns total tax for a given income
// Arrays: [Upper Limit, Rate]
var brackets = [];
if (status === 'single') {
brackets = [
[11600, 0.10], [47150, 0.12], [100525, 0.22],
[191950, 0.24], [243725, 0.32], [609350, 0.35], [Infinity, 0.37]
];
} else if (status === 'married_joint') {
brackets = [
[23200, 0.10], [94300, 0.12], [201050, 0.22],
[383900, 0.24], [487450, 0.32], [731200, 0.35], [Infinity, 0.37]
];
} else { // Head of Household
brackets = [
[16550, 0.10], [63100, 0.12], [100500, 0.22],
[191950, 0.24], [243700, 0.32], [609350, 0.35], [Infinity, 0.37]
];
}
var tax = 0;
var previousLimit = 0;
for (var i = 0; i previousLimit) {
var taxableAmount = Math.min(income, limit) – previousLimit;
tax += taxableAmount * rate;
previousLimit = limit;
} else {
break;
}
}
return tax;
}
function formatMoney(amount) {
return '$' + amount.toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2});
}