If you sell your home and realize a taxable gain even after the exclusion, you can reduce your gain with selling costs.
Your gain is defined as your home’s selling price, minus deductible closing costs, minus your basis. The basis is the original purchase price of the home, plus improvements, less any depreciation.
Real estate broker’s commissions, title insurance, legal fees, administrative costs, and inspection fees are all considered to be selling costs.