Short Term (Less than 1 year)
Long Term (More than 1 year)
Total Capital Gain:$0.00
Tax Classification:Long Term
Estimated Tax Rate:0%
Estimated Tax Due:$0.00
Net Profit (After Tax):$0.00
function calculateCapGains() {
// 1. Get Values
var purchasePrice = parseFloat(document.getElementById('cgtPurchasePrice').value);
var salePrice = parseFloat(document.getElementById('cgtSalePrice').value);
var income = parseFloat(document.getElementById('cgtAnnualIncome').value);
var status = document.getElementById('cgtFilingStatus').value;
var duration = document.getElementById('cgtDuration').value;
var resultBox = document.getElementById('cgtResultBox');
// 2. Validate
if (isNaN(purchasePrice) || isNaN(salePrice) || isNaN(income)) {
alert("Please enter valid numbers for prices and income.");
return;
}
// 3. Logic
var gain = salePrice – purchasePrice;
var taxRate = 0;
var taxAmount = 0;
var classification = "";
if (gain <= 0) {
// Loss
taxRate = 0;
taxAmount = 0;
classification = "Loss (No Tax)";
} else {
if (duration === 'short') {
classification = "Short Term (Ordinary Income)";
// Short term uses standard income brackets.
// For simplicity in this frontend tool, we estimate based on the top marginal rate
// determined by the user's Annual Income.
// 2024 Bracket Approximations for Single:
if (status === 'single') {
if (income < 11600) taxRate = 0.10;
else if (income < 47150) taxRate = 0.12;
else if (income < 100525) taxRate = 0.22;
else if (income < 191950) taxRate = 0.24;
else if (income < 243725) taxRate = 0.32;
else if (income < 609350) taxRate = 0.35;
else taxRate = 0.37;
} else if (status === 'married') {
if (income < 23200) taxRate = 0.10;
else if (income < 94300) taxRate = 0.12;
else if (income < 201050) taxRate = 0.22;
else if (income < 383900) taxRate = 0.24;
else if (income < 487450) taxRate = 0.32;
else if (income < 731200) taxRate = 0.35;
else taxRate = 0.37;
} else {
// Head of household approx
if (income < 16550) taxRate = 0.10;
else if (income < 63100) taxRate = 0.12;
else if (income < 100500) taxRate = 0.22;
else if (income < 191950) taxRate = 0.24;
else if (income < 243700) taxRate = 0.32;
else if (income < 609350) taxRate = 0.35;
else taxRate = 0.37;
}
} else {
classification = "Long Term (Capital Gains Rate)";
// Long term rates: 0%, 15%, 20%
// 2024 Thresholds
if (status === 'single') {
if (income <= 47025) taxRate = 0.0;
else if (income <= 518900) taxRate = 0.15;
else taxRate = 0.20;
} else if (status === 'married') {
if (income <= 94050) taxRate = 0.0;
else if (income <= 583750) taxRate = 0.15;
else taxRate = 0.20;
} else {
// Head of household
if (income <= 63000) taxRate = 0.0;
else if (income <= 551350) taxRate = 0.15;
else taxRate = 0.20;
}
}
taxAmount = gain * taxRate;
}
var netProfit = gain – taxAmount;
// 4. Output Formatting
var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
});
document.getElementById('resTotalGain').innerText = formatter.format(gain);
document.getElementById('resClass').innerText = classification;
document.getElementById('resRate').innerText = (taxRate * 100).toFixed(1) + "%";
document.getElementById('resTaxDue').innerText = formatter.format(taxAmount);
document.getElementById('resNetProfit').innerText = formatter.format(netProfit);
resultBox.style.display = 'block';
}
Understanding Capital Gains Tax in 2024 and 2025
Whether you are selling stocks, real estate, or cryptocurrency, understanding your potential tax liability is crucial for financial planning. This Capital Gains Tax Calculator helps investors estimate the taxes owed based on current IRS brackets and their filing status.
Key Takeaway: The length of time you hold an asset significantly impacts your tax rate. Assets held for more than one year qualify for lower "Long-Term" tax rates.
Short-Term vs. Long-Term Capital Gains
The IRS treats profits from the sale of assets differently depending on how long you owned the asset before selling it:
Short-Term Capital Gains: Applies to assets held for one year or less. These profits are taxed as ordinary income, meaning they are taxed at the same rate as your wages or salary (up to 37%).
Long-Term Capital Gains: Applies to assets held for more than one year. These profits benefit from preferential tax rates of 0%, 15%, or 20%, depending on your total taxable income.
How to Calculate Your Capital Gains
To use the calculator above effectively, you need three main pieces of information:
Cost Basis: This is generally the original purchase price of the asset, plus any fees paid (like commissions) and improvements made (for real estate).
Sale Price: The final amount you sold the asset for, minus any selling expenses.
Taxable Income: Your total income determines which tax bracket you fall into, which defines your capital gains rate.
2024 Long-Term Capital Gains Tax Brackets
For the 2024 tax year (taxes filed in 2025), the long-term capital gains rates are broken down by income thresholds. For example, a single filer with a taxable income under $47,025 pays 0% on long-term capital gains.
Income between $47,026 and $518,900 usually incurs a 15% tax rate, while income above $518,900 is taxed at the maximum 20% rate (plus potential Net Investment Income Tax for high earners).
Strategies to Reduce Capital Gains Tax
Investors often use specific strategies to minimize their tax burden:
Hold for over a year: Waiting until the 366th day to sell can drop your tax rate from 37% down to 20% or even 15%.
Tax-Loss Harvesting: Selling underperforming assets at a loss can offset the gains realized from other sales, lowering your total taxable gain.
Use Tax-Advantaged Accounts: Trading within a 401(k) or IRA does not trigger immediate capital gains taxes.