Deductions & credits

the exclusion is available if you owned and occupied the residence for any 2 years (24 months/730 days not necessarily consecutive) out of 5 years before sale. also, you can not have used the HSE if you used it within 2 years of this sale

 

as to cost

1)there's the purchase price (the mortgage is irrelevant)

2) closing costs on purchase such as title fees, survey fees, recording fees, title costs, home inspection fee (the best source would be you closing statement on purchase - note may items on it are considered personal expenses which are not includable in the cost such as mortgage acquisition costs)  terminology can differ from location to location - Turbotax premier and above and all desktop versions include a home sale worksheet which would help you.

3) capital improvements

4) less and depreciation allowed or allowable if used as a rental or home office

5) seller credits and certain rebates such as from the title company

 

your sales price as adjusted

Your sales price (again the mortgage payoff is ignored)

Less

selling expenses such as realtors commission, home inspection fee, home warranty fee, transfer tax  

certain credits given to buyer

 

gain sales price as adjusted less cost

 

the list of items is not all inclusive 

for actual reporting the selling expenses are treated as an addition to your cost