Calculate your potential capital gains tax liability.
Your Estimated Capital Gains Tax
—
Understanding Capital Gains Tax
Capital gains tax is levied on the profit made from selling an asset that has increased in value since you acquired it. This profit is known as the capital gain. Assets that can incur capital gains tax include stocks, bonds, real estate, and other investments.
How Capital Gains Are Calculated:
The fundamental calculation for capital gains involves determining the difference between the selling price and the adjusted cost basis of the asset. The adjusted cost basis includes the original purchase price plus any additional costs associated with acquiring and improving the asset, minus any depreciation (if applicable).
The formula is:
Capital Gain = Selling Price - (Purchase Price + Commissions & Costs + Capital Improvements - Depreciation)
In this calculator, we simplify this to:
Capital Gain = Selling Price - (Purchase Price + Commissions & Costs + Capital Improvements)
Short-Term vs. Long-Term Capital Gains:
The tax treatment of capital gains depends on how long you held the asset:
Short-Term Capital Gains: If you held the asset for one year or less, the gain is considered short-term. These gains are typically taxed at your ordinary income tax rate.
Long-Term Capital Gains: If you held the asset for more than one year, the gain is considered long-term. These gains are generally taxed at lower, preferential rates, which vary based on your income bracket.
How This Calculator Works:
Enter Asset Details: Input the purchase price, selling price, dates of purchase and sale, and any associated costs like commissions, fees, or capital improvements.
Determine Holding Period: The calculator will determine if your gain is short-term or long-term based on the purchase and selling dates.
Calculate Capital Gain: It subtracts your total costs (purchase price, commissions, improvements) from the selling price to find the total gain.
Apply Tax Rate: It then applies the appropriate short-term or long-term capital gains tax rate to the calculated gain to estimate your tax liability.
Important Considerations:
Tax laws can be complex and vary by jurisdiction. This calculator provides an estimate only.
This calculator does not account for depreciation, capital losses, or specific tax deductions and exemptions that might apply to your situation.
Consult with a qualified tax professional for personalized advice.
Example Scenario:
Let's say you bought a stock for $10,000 (Purchase Price) on 2020-01-15. You paid $100 in commission fees (Commissions & Costs). You made significant improvements to a property bought for $200,000 (Purchase Price) on 2021-03-10, costing you $15,000 (Capital Improvements). You sell your stock for $25,000 (Selling Price) on 2023-07-20, incurring $200 in selling fees (Commissions & Costs). Your short-term tax rate is 25% and your long-term rate is 15%.
For the stock:
Holding Period: 3 years and 6 months (Long-Term)
Total Costs: $10,000 (Purchase) + $100 (Commissions) = $10,100
Capital Gain: $25,000 (Selling) – $10,100 (Total Costs) = $14,900
function calculateCapitalGains() {
var purchasePrice = parseFloat(document.getElementById("purchasePrice").value);
var sellingPrice = parseFloat(document.getElementById("sellingPrice").value);
var purchaseDateStr = document.getElementById("purchaseDate").value;
var sellingDateStr = document.getElementById("sellingDate").value;
var shortTermRate = parseFloat(document.getElementById("shortTermRate").value);
var longTermRate = parseFloat(document.getElementById("longTermRate").value);
var commissionCosts = parseFloat(document.getElementById("commissionCosts").value);
var improvementsCost = parseFloat(document.getElementById("improvementsCost").value);
var resultValueElement = document.getElementById("result-value");
var resultLabelElement = document.getElementById("result-label");
// Clear previous results
resultValueElement.innerText = "–";
resultLabelElement.innerText = "Your Estimated Capital Gains Tax";
// Validate inputs
if (isNaN(purchasePrice) || isNaN(sellingPrice) || isNaN(shortTermRate) || isNaN(longTermRate) || isNaN(commissionCosts) || isNaN(improvementsCost) ||
purchasePrice < 0 || sellingPrice < 0 || shortTermRate < 0 || longTermRate < 0 || commissionCosts < 0 || improvementsCost < 0) {
alert("Please enter valid positive numbers for all price and rate fields.");
return;
}
var purchaseDate = new Date(purchaseDateStr);
var sellingDate = new Date(sellingDateStr);
if (isNaN(purchaseDate.getTime()) || isNaN(sellingDate.getTime())) {
alert("Please enter valid dates in YYYY-MM-DD format.");
return;
}
if (sellingDate < purchaseDate) {
alert("Selling date cannot be before the purchase date.");
return;
}
// Calculate holding period in days
var timeDiff = sellingDate.getTime() – purchaseDate.getTime();
var holdingDays = timeDiff / (1000 * 3600 * 24);
// Determine if short-term or long-term
var isShortTerm = holdingDays <= 365; // 365 days or less is considered short-term
// Calculate total adjusted cost basis
var adjustedCostBasis = purchasePrice + commissionCosts + improvementsCost;
// Calculate capital gain
var capitalGain = sellingPrice – adjustedCostBasis;
// Ensure capital gain is not negative (losses are not calculated here)
if (capitalGain < 0) {
capitalGain = 0;
}
// Determine tax rate
var taxRate = isShortTerm ? (shortTermRate / 100) : (longTermRate / 100);
// Calculate capital gains tax
var capitalGainsTax = capitalGain * taxRate;
// Display result
if (capitalGain === 0) {
resultLabelElement.innerText = "No Capital Gain";
resultValueElement.innerText = "$0.00";
} else {
resultLabelElement.innerText = "Estimated Capital Gains Tax (" + (isShortTerm ? "Short-Term" : "Long-Term") + ")";
resultValueElement.innerText = "$" + capitalGainsTax.toFixed(2);
}
}