.cgt-calculator-wrapper {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
max-width: 800px;
margin: 20px auto;
border: 1px solid #e2e8f0;
border-radius: 8px;
overflow: hidden;
background-color: #ffffff;
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
.cgt-header {
background-color: #2c3e50;
color: white;
padding: 20px;
text-align: center;
}
.cgt-header h2 {
margin: 0;
font-size: 24px;
}
.cgt-body {
padding: 30px;
display: flex;
flex-wrap: wrap;
gap: 30px;
}
.cgt-inputs {
flex: 1;
min-width: 300px;
}
.cgt-results {
flex: 1;
min-width: 300px;
background-color: #f8fafc;
padding: 20px;
border-radius: 8px;
display: none; /* Hidden until calculated */
border: 1px solid #e2e8f0;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: 600;
color: #4a5568;
font-size: 14px;
}
.form-group input, .form-group select {
width: 100%;
padding: 10px;
border: 1px solid #cbd5e0;
border-radius: 4px;
font-size: 16px;
box-sizing: border-box;
}
.form-group input:focus, .form-group select:focus {
outline: none;
border-color: #4299e1;
box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
}
.input-group-symbol {
position: relative;
}
.input-group-symbol span {
position: absolute;
left: 10px;
top: 50%;
transform: translateY(-50%);
color: #718096;
}
.input-group-symbol input {
padding-left: 25px;
}
.btn-calc {
width: 100%;
padding: 12px;
background-color: #48bb78;
color: white;
border: none;
border-radius: 4px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
transition: background-color 0.2s;
margin-top: 10px;
}
.btn-calc:hover {
background-color: #38a169;
}
.result-row {
display: flex;
justify-content: space-between;
margin-bottom: 12px;
padding-bottom: 12px;
border-bottom: 1px solid #e2e8f0;
}
.result-row:last-child {
border-bottom: none;
}
.result-label {
color: #4a5568;
font-size: 14px;
}
.result-value {
font-weight: bold;
color: #2d3748;
font-size: 16px;
}
.total-tax-row .result-value {
color: #e53e3e;
}
.net-profit-row .result-value {
color: #38a169;
font-size: 18px;
}
.cgt-content {
padding: 30px;
border-top: 1px solid #e2e8f0;
background-color: #fafafa;
color: #2d3748;
line-height: 1.6;
}
.cgt-content h3 {
margin-top: 0;
color: #2c3e50;
}
.cgt-content p {
margin-bottom: 15px;
}
.cgt-content ul {
margin-bottom: 15px;
padding-left: 20px;
}
@media (max-width: 600px) {
.cgt-body {
flex-direction: column;
}
}
Tax Breakdown
Total Capital Gain:
$0.00
Tax Type Applied:
–
Estimated Federal Tax Rate:
0%
Estimated Tax Owed:
$0.00
Net Profit After Tax:
$0.00
*Estimates based on 2024 Federal tax brackets. Does not include state taxes.
Understanding Your Capital Gains Tax
When you sell an asset (like stocks, real estate, or cryptocurrency) for more than you paid for it, the profit is considered a "capital gain." The IRS taxes these gains differently depending on how long you held the asset and your total taxable income.
Short-Term vs. Long-Term Gains
The duration of ownership is the most critical factor in calculating your tax liability:
- Short-Term Capital Gains: Assets held for one year or less. These are taxed as ordinary income, meaning they are added to your salary and other earnings and taxed at 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 of 0%, 15%, or 20%, depending on your income level and filing status.
Net Investment Income Tax (NIIT)
High-income earners may also be subject to an additional 3.8% Net Investment Income Tax. This applies if your Modified Adjusted Gross Income (MAGI) exceeds specific thresholds (e.g., $200,000 for single filers or $250,000 for married couples filing jointly).
Strategies to Lower Capital Gains Tax
Investors often use strategies like Tax-Loss Harvesting (selling losing assets to offset gains) or holding assets for over a year to qualify for long-term rates to minimize their tax burden. Always consult with a qualified CPA or tax professional for advice tailored to your specific financial situation.
function calculateCapitalGains() {
// 1. Get Input Values
var purchasePrice = parseFloat(document.getElementById('purchasePrice').value);
var salePrice = parseFloat(document.getElementById('salePrice').value);
var annualIncome = parseFloat(document.getElementById('annualIncome').value);
var filingStatus = document.getElementById('filingStatus').value;
var duration = document.getElementById('ownershipDuration').value;
// 2. Validate Inputs
if (isNaN(purchasePrice) || isNaN(salePrice) || isNaN(annualIncome)) {
alert("Please enter valid numbers for Purchase Price, Sale Price, and Annual Income.");
return;
}
// 3. Calculate Gain
var gain = salePrice – purchasePrice;
// 4. Initialize Tax Variables
var taxOwed = 0;
var taxRateDisplay = "0%";
var taxTypeDisplay = "";
// 5. Logic
if (gain <= 0) {
// Loss or Breakeven
taxOwed = 0;
taxRateDisplay = "N/A (Loss)";
taxTypeDisplay = "None";
} else {
// We have a gain
if (duration === 'short') {
// Short Term Logic: Taxed as Ordinary Income
taxTypeDisplay = "Ordinary Income (Short Term)";
// Estimate Marginal Tax Rate based on 2024 Brackets (Simplified)
// We determine the rate based on Total Income (Annual + Gain)
var totalIncome = annualIncome + gain;
var marginalRate = 0;
// 2024 Federal Brackets for Single
if (filingStatus === 'single') {
if (totalIncome <= 11600) marginalRate = 0.10;
else if (totalIncome <= 47150) marginalRate = 0.12;
else if (totalIncome <= 100525) marginalRate = 0.22;
else if (totalIncome <= 191950) marginalRate = 0.24;
else if (totalIncome <= 243725) marginalRate = 0.32;
else if (totalIncome <= 609350) marginalRate = 0.35;
else marginalRate = 0.37;
}
// 2024 Federal Brackets for Married Filing Jointly
else if (filingStatus === 'married_joint') {
if (totalIncome <= 23200) marginalRate = 0.10;
else if (totalIncome <= 94300) marginalRate = 0.12;
else if (totalIncome <= 201050) marginalRate = 0.22;
else if (totalIncome <= 383900) marginalRate = 0.24;
else if (totalIncome <= 487450) marginalRate = 0.32;
else if (totalIncome <= 731200) marginalRate = 0.35;
else marginalRate = 0.37;
}
// 2024 Federal Brackets for Head of Household
else {
if (totalIncome <= 16550) marginalRate = 0.10;
else if (totalIncome <= 63100) marginalRate = 0.12;
else if (totalIncome <= 100500) marginalRate = 0.22;
else if (totalIncome <= 191950) marginalRate = 0.24;
else if (totalIncome <= 243700) marginalRate = 0.32;
else if (totalIncome <= 609350) marginalRate = 0.35;
else marginalRate = 0.37;
}
taxOwed = gain * marginalRate;
taxRateDisplay = (marginalRate * 100).toFixed(1) + "% (Est. Marginal)";
} else {
// Long Term Logic: 0%, 15%, 20%
taxTypeDisplay = "Capital Gains (Long Term)";
var rate = 0;
// 2024 Capital Gains Brackets
if (filingStatus === 'single') {
if (annualIncome <= 47025) rate = 0;
else if (annualIncome <= 518900) rate = 0.15;
else rate = 0.20;
} else if (filingStatus === 'married_joint') {
if (annualIncome <= 94050) rate = 0;
else if (annualIncome <= 583750) rate = 0.15;
else rate = 0.20;
} else { // Head of Household
if (annualIncome <= 63000) rate = 0;
else if (annualIncome Threshold, add 3.8% to the rate for this estimation tool
if (annualIncome > niitThreshold) {
niit = 0.038;
taxTypeDisplay += " + 3.8% NIIT";
}
var totalRate = rate + niit;
taxOwed = gain * totalRate;
taxRateDisplay = (totalRate * 100).toFixed(1) + "%";
}
}
// 6. Final Numbers
var netProfit = gain – taxOwed;
// 7. Update UI
document.getElementById('displayTotalGain').innerHTML = formatCurrency(gain);
document.getElementById('displayTaxType').innerHTML = taxTypeDisplay;
document.getElementById('displayTaxRate').innerHTML = taxRateDisplay;
document.getElementById('displayTaxOwed').innerHTML = formatCurrency(taxOwed);
document.getElementById('displayNetProfit').innerHTML = formatCurrency(netProfit);
// Show results
document.getElementById('resultsArea').style.display = 'block';
}
function formatCurrency(num) {
return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(num);
}