Selling your home can be both exciting and financially rewarding, but understanding how to calculate capital gains on a house sale is crucial to avoid surprises. Whether you’re selling for a profit or just want to know what taxes you might owe, calculating capital gains is an essential step. In this guide, we’ll walk you through how to determine your capital gain, the cost basis, exclusions you may qualify for, and the various taxes that apply. With clear examples, you’ll learn exactly how much you can keep from the sale and how much might go to taxes.

- Key Takeaways
- Example of House Sale
- Determine the Cost Basis
- Calculate the Capital Gain
- Apply Exclusions to Calculate the Taxable Capital Gain
- Calculate the Federal Capital Gains Tax
- Calculate the State Capital Gains Tax (If Applicable)
- Calculate the Net Investment Income Tax (NIIT)
- Calculate the Total Tax on the Sale of the House
- Calculate the Net Process from the Sale

## Key Takeaways

**Understand the Cost Basis**: Your home’s cost basis includes the purchase price, major home improvements, and transaction costs, all crucial in determining your capital gain.**Federal Exclusions**: Homeowners may be able to exclude up to $250,000 ($500,000 for married couples) of capital gains if certain criteria are met.**Tax Brackets Matter**: Capital gains are taxed at varying rates depending on your total income, with federal tax rates ranging from 0% to 20%.**NIIT and State Taxes**: High-income earners may face additional taxes like the 3.8% NIIT and state capital gains taxes, adding to the total tax burden.

## Example of House Sale

In this example, we’ll use the following values in the table below. We’ll assume that there is not an outstanding mortgage on the house, which really doesn’t impact the majority of this analysis.

Seller Variables | Amount |
---|---|

Ordinary income (excluding the capital gain) | $20,000 |

Sale price | $1,000,000 |

Purchase price | $200,000 |

Home improvements | $15,000 |

Sales commission | 3% |

Capital gains exclusion (federal, single filer) | $250,000 |

Local transfer taxes | $2,750 |

State income tax rate | 5% |

Net Investment Income Tax | 3.8% |

**Determine the Cost Basis**

The cost basis is the original value or purchase price of the house, plus certain expenses such as:

**Transaction costs:**Costs like real estate sales commission, legal fees, title fees, and other closing costs.**Home improvements:**This includes major renovations or additions that increase the property’s value, such as adding a new roof or upgrading the kitchen.**Depreciation:**For investment properties, any depreciation claimed over the years must be subtracted from the cost basis.

In our example, we’ll use the sales commission as the only transaction cost, and we’ll put aside the depreciation for simplicity. The cost basis is calculated as follows:

**Purchase Price** ($200,000) + **Home Improvements** ($15,000) + **Sales Commission** (3% x $1,000,000 = $30,000)

So, the **Cost Basis** is $245,000.

**Calculate the Capital Gain**

The capital gain is calculated as follows:

**Capital Gain** = **Sale Price** – **Cost Basis** = $1,000,000 – $245,000 = $755,000

**Apply Exclusions **to Calculate the Taxable Capital Gain

For homeowners, the IRS allows you to exclude a portion of the capital gains from taxes if the home has been your primary residence for at least two out of the last five years. The capital gain exclusion amounts are:

**$250,000**for single filers.**$500,000**for married couples filing jointly.

Using our example, if you’re single and qualify for the exclusion, you can subtract $250,000 from your capital gain:

**Taxable Capital Gain** = **Capital Gain** – **Capital Gain Exclusion** = $755,000 – $250,000 = $505,000

**Calculate the Federal Capital Gains Tax**

If your taxable gain exceeds the exclusion, the remaining gain is subject to federal capital gains taxes. The tax rate (using 2024 rates) depends on how long you held the asset:

**Short-term capital gains**(assets held for one year or less): Taxed at ordinary income tax rates (10% to 37% depending on your tax bracket).**Long-term capital gains**(assets held for more than one year): Taxed at a lower rate, typically 0%, 15%, or 20%, depending on your income.

In our example, the house sale is considered a long-term capital gain because the house has been held for longer than 5 years.

### Filling Up the Brackets

Now the math gets a bit tricky, so I’m devoting an entire section to explain this. I’ve researched this for hours, and as far as I can tell, nobody has clearly explained the way that this works.

These particular tax brackets are based on your taxable income, which includes ordinary income (such as wages) and capital gains. The IRS uses these brackets to figure out how much of your capital gains are taxed at 0%, 15%, and 20%:

Tax Rate | Single | Married Filing Jointly | Married Filing Separately | Head of Household |
---|---|---|---|---|

0% | $0 to $47,025 | $0 to $94,050 | $0 to $47,025 | $0 to $63,000 |

15% | $47,026 to $518,900 | $94,051 to $583,750 | $47,026 to $291,850 | $63,001 to $551,350 |

20% | $518,901 or more | $583,751 or more | $291,851 or more | $551,351 or more |

### Filling Up the 0% Bracket

In our example, the ordinary income ($20,000) takes up part of the 0% bracket. As a single filer, the 0% capital gains tax rate applies to the first $47,025 of your **total income**. If you already have $20,000 in ordinary income, that fills part of the 0% capital gains bracket, leaving the remaining $27,025 ($47,025 – $20,000) to apply to your capital gains. So, $27,025 is taxed at 0%, meaning no taxes on this amount!

### Filling Up the 15% Bracket

After filling up the 0% bracket, any amount that pushes your taxable income (ordinary income + capital gains) beyond $47,025 falls into the 15% bracket and possibly the 20% bracket. With $505,000 in capital gains, after filling the 0% bracket with $27,025, that leaves $477,975 of capital gains that must be considered.

The 15% bracket goes up to $518,900 in total income, so we subtract the 0% threshold of $47,025 from the 15% threshold of $518,900 to see that the 15% bracket has a space of $471,875. The remaining $477,975 we previously calculated completely fills up this bracket, so we apply the 15% tax rate to the entire $471,875:

$471,875 x 15% = $70,781 in capital gain taxes so far.

### Filling Up the 20% Bracket

After accounting for the 0% bracket (in which $27,025 was taxed) and the 15% bracket (in which $471,875 was taxed), we still have some capital gains left that are subject to tax. The remaining portion of the capital gain is:

$505,000 − ($27,025 + $471,875) = $6,100. We apply the 20% tax rate to this portion of the capital gains.

$6,100 x 20% = $1,220 in additional capital gain taxes.

### Summing Up the Federal Capital Gains Tax

Summing up the federal capital gains tax:

**Federal Capital Gains Tax** = $70,781 (from the 15% bracket) + $1,220 (from the 20% bracket) = $72,001

**Calculate the State Capital Gains Tax** (If Applicable)

States in the U.S. have varying approaches to taxing capital gains, with some states imposing no tax on these gains at all, while others treat them as ordinary income subject to state income tax rates. In this example, we’ll assume a tax rate of 5% on the capital gain:

**State Capital Gains Tax** = **Taxable Capital Gain **x 5% = $505,000 x 5% = $25,250

## Calculate the Net Investment Income Tax (NIIT)

The **Net Investment Income Tax (NIIT)** is a 3.8% federal tax that applies to certain types of investment income for high-income earners. It is based on your modified adjusted gross income (MAGI), which includes capital gains. In this example, the MAGI is the ordinary income ($20,000) plus the capital gain ($505,000), for a total of $525,000.

So, while you might not consider yourself a high-income earner, the sale of your house can bestow that honor on you, at least for the year in which you sell your house.

NIIT thresholds are based on your tax filing status and MAGI as follows:

Filing Status | Income Threshold |
---|---|

Single | $200,000 |

Married filing jointly | $250,000 |

Married filing separately | $125,000 |

Head of household | $200,000 |

Qualified widow or widower with a child | $250,000 |

To calculate the NIIT, the IRS only taxes the smaller amount of:

- Your net investment income ($505,000 in our example).
- The amount your MAGI exceeds the threshold ($525,000 – $200,000 = $325,000).

The smaller of these two is $325,000, so the NIIT is:

**NIIT** = $325,000 x 3.8% = $12,350

For more information on NIIT, see Net Investment Income Tax (NIIT): How to Plan and Minimize Costs.

## Calculate the Total Tax on the Sale of the House

The total tax on the sale of the house is the sum of the following:

- Federal capital gains tax: $72,001
- State capital gains tax: $25,250
- NIIT: $12,350
- Local transfer taxes: $2,750

**Total tax on sale of house**: $112,351

## Calculate the Net Process from the Sale

In this example, the lucky seller will end up with a funds transfer of $887,649 ($1,000,000 – $112,351) into their account. However, the net gain of the sale is $887,649 minus the original purchase price of $200,000, which nets the seller $687,649.

For more information, you can review the IRS Publication 523 ↗ on how to sell your home and IRS Topic No. 409 ↗ for more about capital gains and losses.

To learn more about capital gains in general, nerdwallet ↗ provides a great article and calculator to help you out.