Sales Tax Rate Calculator Math

Capital Gains Tax Calculator 2024 :root { –primary-color: #2c3e50; –accent-color: #27ae60; –bg-color: #f8f9fa; –text-color: #333; –border-radius: 8px; } body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; line-height: 1.6; color: var(–text-color); margin: 0; padding: 20px; background-color: var(–bg-color); } .cgt-wrapper { max-width: 800px; margin: 0 auto; background: #fff; padding: 40px; border-radius: var(–border-radius); box-shadow: 0 4px 6px rgba(0,0,0,0.1); } .cgt-header { text-align: center; margin-bottom: 30px; } .cgt-header h1 { color: var(–primary-color); margin-bottom: 10px; } .cgt-calculator-box { background: #f1f8e9; padding: 30px; border-radius: var(–border-radius); border: 1px solid #c8e6c9; } .cgt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; } @media (max-width: 600px) { .cgt-grid { grid-template-columns: 1fr; } .cgt-wrapper { padding: 20px; } } .cgt-input-group { margin-bottom: 15px; } .cgt-input-group label { display: block; margin-bottom: 5px; font-weight: 600; color: var(–primary-color); } .cgt-input-group input, .cgt-input-group select { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; box-sizing: border-box; } .cgt-input-group input:focus, .cgt-input-group select:focus { border-color: var(–accent-color); outline: none; } .cgt-btn { width: 100%; padding: 15px; background-color: var(–accent-color); color: white; border: none; border-radius: 4px; font-size: 18px; font-weight: bold; cursor: pointer; transition: background-color 0.3s; margin-top: 10px; } .cgt-btn:hover { background-color: #219150; } .cgt-results { margin-top: 30px; display: none; border-top: 2px solid #ddd; padding-top: 20px; } .cgt-result-card { background: white; padding: 20px; border-radius: var(–border-radius); box-shadow: 0 2px 4px rgba(0,0,0,0.05); text-align: center; margin-bottom: 20px; } .cgt-result-card h3 { margin: 0; color: var(–primary-color); font-size: 16px; text-transform: uppercase; letter-spacing: 1px; } .cgt-result-value { font-size: 32px; font-weight: 800; color: var(–accent-color); margin: 10px 0; } .cgt-result-sub { font-size: 14px; color: #666; } .cgt-article { margin-top: 50px; } .cgt-article h2, .cgt-article h3 { color: var(–primary-color); } .cgt-article p { margin-bottom: 15px; } .cgt-alert { color: #e74c3c; font-size: 14px; margin-top: 5px; display: none; }

Capital Gains Tax Calculator

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); }

Leave a Comment