Calculate your net profit and estimated tax liability on asset sales.
Adjusted Cost Basis:
Net Selling Proceeds:
Total Capital Gain/Loss:
Estimated Tax Owed:
Net Profit After Tax:
function calculateCapitalGains() {
var buyPrice = parseFloat(document.getElementById('buyPrice').value) || 0;
var sellPrice = parseFloat(document.getElementById('sellPrice').value) || 0;
var buyCosts = parseFloat(document.getElementById('buyCosts').value) || 0;
var sellCosts = parseFloat(document.getElementById('sellCosts').value) || 0;
var improvements = parseFloat(document.getElementById('improvements').value) || 0;
var taxRate = parseFloat(document.getElementById('taxRate').value) || 0;
// Adjusted Cost Basis = Purchase Price + Purchase Costs + Improvements
var adjustedBasis = buyPrice + buyCosts + improvements;
// Net Proceeds = Selling Price – Selling Costs
var netProceeds = sellPrice – sellCosts;
// Capital Gain = Net Proceeds – Adjusted Basis
var capitalGain = netProceeds – adjustedBasis;
// Tax Owed (only if gain is positive)
var taxOwed = 0;
if (capitalGain > 0) {
taxOwed = capitalGain * (taxRate / 100);
}
var netProfit = capitalGain – taxOwed;
// Display Results
document.getElementById('cgResults').style.display = 'block';
document.getElementById('resAdjustedBasis').innerText = adjustedBasis.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById('resNetProceeds').innerText = netProceeds.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
var gainElement = document.getElementById('resCapitalGain');
gainElement.innerText = capitalGain.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
if (capitalGain < 0) {
gainElement.className = 'cg-result-value cg-loss';
} else {
gainElement.className = 'cg-result-value';
}
document.getElementById('resTaxOwed').innerText = taxOwed.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
var profitElement = document.getElementById('resNetProfit');
profitElement.innerText = netProfit.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
if (netProfit < 0) {
profitElement.className = 'cg-result-value cg-loss';
} else {
profitElement.className = 'cg-result-value';
}
}
How to Calculate Capital Gains: A Step-by-Step Guide
Calculating capital gains is a critical skill for investors in real estate, stocks, or any other appreciable asset. At its simplest level, a capital gain is the profit you realize when you sell an asset for more than its "basis." However, to avoid overpaying taxes, you must understand the concept of the Adjusted Cost Basis.
Step 1: Determine the Purchase Price and Purchase Costs
Your starting point is the original price you paid for the asset. To this, you should add any costs incurred during the acquisition. For real estate, this includes legal fees, title insurance, and transfer taxes. This combined figure is your initial cost basis.
Step 2: Add Capital Improvements
One of the most common mistakes is forgetting to include improvements. A capital improvement is a permanent structural change or restoration that adds value to the property, prolongs its useful life, or adapts it to new uses.
Included: Adding a new roof, finishing a basement, or installing a HVAC system.
Excluded: General repairs and maintenance, such as fixing a leaky faucet or painting a room.
Adding these to your initial basis gives you your Adjusted Cost Basis.
Step 3: Calculate Net Selling Proceeds
When you sell the asset, you don't keep the entire check. You must subtract the costs of the sale. This usually includes agent commissions, advertising fees, and closing costs. The amount left over is your Net Selling Proceeds.
Step 4: The Final Calculation
The formula for capital gains is:
Capital Gain = Net Selling Proceeds – Adjusted Cost Basis
Real-World Example
Imagine you bought a rental property for 250,000. You paid 5,000 in closing costs. Over five years, you spent 30,000 on a kitchen remodel. Your Adjusted Cost Basis is now 285,000.
You sell the property for 400,000 but pay a 6% commission (24,000). Your Net Proceeds are 376,000.
Your Capital Gain is 376,000 – 285,000 = 91,000. If you are in a 15% long-term capital gains tax bracket, you would owe 13,650 in taxes.
Short-Term vs. Long-Term Gains
The length of time you hold the asset is crucial for tax purposes:
Short-Term: Assets held for one year or less are taxed at ordinary income tax rates (usually higher).
Long-Term: Assets held for more than one year benefit from preferential tax rates (typically 0%, 15%, or 20% depending on your total income).