More than 1 Year (Long Term)
1 Year or Less (Short Term)
Total Capital Gain:$0.00
Federal Tax Rate Applied:0%
Estimated Federal Tax:$0.00
Estimated State Tax:$0.00
Net Profit (After Tax):$0.00
function calculateCapitalGains() {
// 1. Get Input Values
var purchasePrice = parseFloat(document.getElementById('cgt_purchase_price').value);
var salePrice = parseFloat(document.getElementById('cgt_sale_price').value);
var income = parseFloat(document.getElementById('cgt_income').value);
var status = document.getElementById('cgt_filing_status').value;
var duration = document.getElementById('cgt_duration').value;
var stateRate = parseFloat(document.getElementById('cgt_state_tax').value);
// 2. Validation
if (isNaN(purchasePrice) || isNaN(salePrice) || isNaN(income)) {
alert("Please enter valid numbers for prices and income.");
return;
}
if (isNaN(stateRate)) {
stateRate = 0;
}
// 3. Basic Calculations
var gain = salePrice – purchasePrice;
// Display Logic for Loss
if (gain <= 0) {
document.getElementById('cgt_result_box').style.display = 'block';
document.getElementById('cgt_display_gain').innerHTML = "$" + gain.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById('cgt_display_fed_rate').innerHTML = "N/A (Loss)";
document.getElementById('cgt_display_fed_tax').innerHTML = "$0.00";
document.getElementById('cgt_display_state_tax').innerHTML = "$0.00";
document.getElementById('cgt_display_net').innerHTML = "$" + gain.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
return;
}
var fedTaxRate = 0;
var fedTaxAmount = 0;
var stateTaxAmount = 0;
// 4. Tax Logic
if (duration === 'short') {
// Short Term: Taxed as Ordinary Income (Simplified 2024 Brackets Logic)
// Note: This is a simplified marginal estimate.
if (status === 'single') {
if (income < 11600) fedTaxRate = 0.10;
else if (income < 47150) fedTaxRate = 0.12;
else if (income < 100525) fedTaxRate = 0.22;
else if (income < 191950) fedTaxRate = 0.24;
else if (income < 243725) fedTaxRate = 0.32;
else if (income < 609350) fedTaxRate = 0.35;
else fedTaxRate = 0.37;
} else if (status === 'married') {
if (income < 23200) fedTaxRate = 0.10;
else if (income < 94300) fedTaxRate = 0.12;
else if (income < 201050) fedTaxRate = 0.22;
else if (income < 383900) fedTaxRate = 0.24;
else if (income < 487450) fedTaxRate = 0.32;
else if (income < 731200) fedTaxRate = 0.35;
else fedTaxRate = 0.37;
} else { // Head of household
if (income < 16550) fedTaxRate = 0.10;
else if (income < 63100) fedTaxRate = 0.12;
else if (income < 100500) fedTaxRate = 0.22;
else if (income < 191950) fedTaxRate = 0.24;
else if (income < 243700) fedTaxRate = 0.32;
else if (income < 609350) fedTaxRate = 0.35;
else fedTaxRate = 0.37;
}
} else {
// Long Term: 0%, 15%, or 20% (2024 Brackets)
if (status === 'single') {
if (income <= 47025) fedTaxRate = 0.00;
else if (income <= 518900) fedTaxRate = 0.15;
else fedTaxRate = 0.20;
} else if (status === 'married') {
if (income <= 94050) fedTaxRate = 0.00;
else if (income <= 583750) fedTaxRate = 0.15;
else fedTaxRate = 0.20;
} else { // Head of household
if (income <= 63000) fedTaxRate = 0.00;
else if (income <= 551350) fedTaxRate = 0.15;
else fedTaxRate = 0.20;
}
}
// Calculate Taxes
fedTaxAmount = gain * fedTaxRate;
stateTaxAmount = gain * (stateRate / 100);
var netProfit = gain – fedTaxAmount – stateTaxAmount;
// 5. Update UI
document.getElementById('cgt_result_box').style.display = 'block';
document.getElementById('cgt_display_gain').innerHTML = "$" + gain.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById('cgt_display_fed_rate').innerHTML = (fedTaxRate * 100).toFixed(1) + "% (" + (duration === 'short' ? 'Short Term' : 'Long Term') + ")";
document.getElementById('cgt_display_fed_tax').innerHTML = "$" + fedTaxAmount.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById('cgt_display_state_tax').innerHTML = "$" + stateTaxAmount.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById('cgt_display_net').innerHTML = "$" + netProfit.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
}
Understanding Your Capital Gains Tax Liability
Calculating your capital gains tax is an essential step in financial planning, whether you are selling real estate, stocks, or other investment assets. This Capital Gains Tax Calculator helps you estimate your potential tax bill based on current 2024 federal tax brackets and your filing status.
What is Capital Gains Tax?
Capital gains tax is a levy on the profit realized from the sale of a non-inventory asset. The tax is calculated on the difference between the sale price and the original purchase price (also known as the "cost basis"). It is important to note that you only pay tax on the net profit, not the total revenue from the sale.
Short-Term vs. Long-Term Capital Gains
The duration for which you hold an asset significantly impacts your tax rate:
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 bracket (ranging from 10% to 37%).
Long-Term Capital Gains: Assets held for more than one year. These benefit from preferential tax rates, typically 0%, 15%, or 20%, depending on your taxable income and filing status.
Current Federal Tax Brackets (2024 Estimates)
For long-term assets, the IRS applies specific income thresholds to determine your rate:
0% Rate: For single filers with taxable income up to $47,025 (or $94,050 for married couples filing jointly).
15% Rate: For single filers with income between $47,026 and $518,900.
20% Rate: For single filers with income exceeding $518,900.
Note: High-income earners may also be subject to an additional 3.8% Net Investment Income Tax (NIIT), which this calculator includes in the estimation if applicable logic were expanded for specific thresholds.
How to Use This Calculator
Enter Purchase Price: Input the original cost of the asset.
Enter Sale Price: Input the final selling price.
Annual Income: Enter your total taxable income (excluding this gain) to determine your tax bracket.
Select Duration: Choose whether you held the asset for more or less than a year.
State Tax: If applicable, enter your state's capital gains tax rate estimate.
Disclaimer: This calculator provides estimates based on 2024 tax brackets. Tax laws are complex and subject to change. Deductions, exemptions, and the Net Investment Income Tax (NIIT) may affect your final liability. Always consult with a certified public accountant (CPA) or tax professional for advice specific to your financial situation.