To offset capital gains, you pair them with realized losses from other investments, apply a statutory exclusion or deferral (the home sale exclusion, a 1031 exchange, an installment sale, a charitable gift of the appreciated asset), or hold the asset until death so heirs inherit at stepped-up basis. Which lever fits depends on what you sold, how long you held it, and how much time you have before year-end. Learning how to offset capital gains is mostly about knowing which of these tools your situation actually qualifies for.
Before choosing a strategy, know the rate you’re fighting. If you sold within a year of buying, the profit is a short-term gain taxed at your ordinary income rate, which runs from 10% to 37% for 2026.1Internal Revenue Service. IRS Releases Tax Inflation Adjustments for Tax Year 2026 Hold longer than a year and the gain qualifies for long-term rates of 0%, 15%, or 20%. For 2026, a single filer pays 0% on long-term gains up to $49,450 of taxable income, 15% between $49,451 and $545,500, and 20% above that. Joint filers reach 15% above $98,900 and 20% above $613,700.2Internal Revenue Service. Rev. Proc. 2025-32 – 2026 Inflation-Adjusted Items A short-term gain is worth more effort to offset than a long-term one, because every dollar you shelter is worth more.
Offset Gains With Realized Losses
The most direct offset is a capital loss from another investment sold in the same tax year. The IRS requires a specific netting order: short-term losses first go against short-term gains, and long-term losses against long-term gains. If either category still shows a net loss, that leftover crosses over to reduce the gain in the other category.3Office of the Law Revision Counsel. 26 USC 1222 – Other Terms Relating to Capital Gains and Losses
That order matters. A long-term loss used to shelter a short-term gain effectively saves you more per dollar than the same loss used against a long-term gain, because short-term gains are taxed at rates that can be more than double the long-term rate. Paying attention to which bucket a loss falls into can make a real difference in April.
Tax-Loss Harvesting Before Year-End
Tax-loss harvesting is the practice of selling underperforming investments before December 31 specifically to generate losses that offset gains you’ve already realized. The sale must close by year-end to count, and you must avoid the wash-sale rule. If you sell a security at a loss and buy a “substantially identical” security within 30 days before or after the sale, the IRS disallows the loss. The disallowed amount adds to the basis of the replacement, so it isn’t gone forever, but it won’t help this year.4Office of the Law Revision Counsel. 26 USC 1091 – Loss From Wash Sales of Stock or Securities
The rule reaches further than many investors expect. Rebuying the same stock in your IRA or Roth IRA within the 30-day window still triggers it, and because IRA basis doesn’t adjust the same way, the disallowed loss is effectively lost rather than deferred. A purchase by your spouse during the restricted period counts too. The common workaround is to reinvest in something similar but not substantially identical, such as swapping one large-cap index fund for another that tracks a different index. Each harvested loss goes on Form 8949 with the correct basis, sale price, and any adjustment codes.5Internal Revenue Service. Instructions for Form 8949
When Losses Exceed Gains
If your total capital losses exceed your total capital gains, the excess doesn’t vanish. Up to $3,000 of the remaining net loss ($1,500 if married filing separately) offsets ordinary income like wages or interest.6Office of the Law Revision Counsel. 26 USC 1211 – Limitation on Capital Losses Anything still left carries forward to the next tax year, keeping its character as short-term or long-term, and enters that year’s netting as if realized then. There is no expiration on the carryover; it rolls forward until used up.7Office of the Law Revision Counsel. 26 USC 1212 – Capital Loss Carrybacks and Carryovers The Schedule D instructions include a Capital Loss Carryover Worksheet to calculate what moves and in which category. Skipping it can leave money on the table or produce a deduction the IRS will adjust later.8Internal Revenue Service. 2025 Instructions for Schedule D (Form 1040)
The Home Sale Exclusion
If the gain is on your primary residence, most or all of it can escape tax entirely. Single filers can exclude up to $250,000 of profit; married couples filing jointly can exclude up to $500,000.9Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence
You have to pass two tests. The ownership test asks whether you owned the home for at least two of the five years before the sale. The use test asks whether you lived in it as your primary residence for at least two of those five years. The two years don’t have to be consecutive. For a joint $500,000 exclusion, both spouses must meet the use test, but only one has to meet the ownership test.9Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence If your gain stays within the limit, you generally don’t have to report the sale at all. Only the excess above $250,000 or $500,000 is taxable.
Selling early can still get you a partial exclusion if the sale was triggered by a change in employment, a health reason, or an unforeseen circumstance such as divorce or a natural disaster. The reduced amount is proportional. Live in the home 15 of the required 24 months and your exclusion is 15/24 of the full amount.9Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence
1031 Exchange for Investment Real Estate
A 1031 exchange lets you sell investment or business real estate and defer the entire capital gain by rolling the proceeds into another qualifying real property. Only real property qualifies after the Tax Cuts and Jobs Act. Equipment, vehicles, and other personal property no longer count, and real property held primarily for resale (a flip) doesn’t qualify either.10Office of the Law Revision Counsel. 26 USC 1031 – Exchange of Real Property Held for Productive Use or Investment
The timelines are strict. From the date you transfer the relinquished property, you have 45 days to identify replacement properties in writing and 180 days to close on one of them. Miss either deadline and the whole gain becomes taxable in the year of sale. A qualified intermediary typically holds the proceeds between the sale and the purchase, because taking the cash yourself can disqualify the exchange.10Office of the Law Revision Counsel. 26 USC 1031 – Exchange of Real Property Held for Productive Use or Investment
The gain isn’t forgiven; it’s deferred. Basis from the old property carries over to the new one, so the tax arrives when you eventually sell without doing another exchange. Some investors chain exchanges throughout their careers and hold until death, at which point the heirs inherit at stepped-up basis and the deferred gain effectively disappears.
Donate the Appreciated Asset Instead of Selling
Giving appreciated long-term capital gain property directly to a qualified charity does two things at once. You avoid the capital gains tax you would have paid on a sale, and you get a charitable deduction for the full fair market value on the date of the gift. Selling first and donating the cash is the expensive mistake, because the sale itself triggers the gain.11Office of the Law Revision Counsel. 26 USC 170 – Charitable, Etc., Contributions and Gifts
The deduction for donated long-term capital gain property is capped at 30% of your adjusted gross income for the year, with any unused portion carrying forward up to five additional tax years.12Internal Revenue Service. Charitable Contribution Deductions Documentation tightens as the gift gets larger. Noncash donations claimed at more than $500 require Form 8283. A claimed deduction above $5,000 for a single item or a group of similar items needs a written qualified appraisal from an independent appraiser, and art valued at $20,000 or more requires the full appraisal attached to the return.13Internal Revenue Service. Instructions for Form 8283
Spread the Gain With an Installment Sale
Selling property with payments spread across more than one tax year lets you use the installment method under Section 453. Instead of recognizing the entire gain in the year of sale, you spread the taxable portion across the years you actually receive payments. Each payment is treated as part return of basis, part gain, and part interest income.
Installment reporting is automatic when the payment terms qualify, but you can elect out and take the full gain up front if that produces a better result, such as when you have current-year losses ready to absorb it. The method doesn’t apply to publicly traded stock or to inventory sold in the ordinary course of business. It’s most common on sales of real estate or closely held business interests where the buyer pays over time.
Hold Until Death: Stepped-Up Basis
The most complete offset is one you don’t take yourself. When your heirs inherit an investment, their basis is generally its fair market value on the date of death, not what you originally paid. Stock bought decades ago for $10,000 and worth $200,000 at death gives an heir a $200,000 basis. If they sell for $205,000, only $5,000 is taxable. This is why buy-and-hold strategies and chained 1031 exchanges work so well as estate tools: the gain deferred during life disappears at death.
Gifts during life are different. If someone gives you an asset while alive, you generally take their original cost basis (carryover basis). A stock your uncle bought for $5,000 and gifted to you when it was worth $50,000 still has a $5,000 basis in your hands. Two paths, same asset, potentially $45,000 apart in taxable gain.
Don’t Overlook the NIIT and Estimated Payments
Higher earners owe an extra 3.8% Net Investment Income Tax on top of the regular capital gains rate. The NIIT applies to the lesser of net investment income or the amount by which modified adjusted gross income exceeds the threshold for your filing status:14Internal Revenue Service. Topic No. 559, Net Investment Income Tax
- $250,000 for married filing jointly
- $200,000 for single or head of household
- $125,000 for married filing separately
These thresholds aren’t indexed for inflation, so more filers cross them each year. Net investment income covers capital gains, dividends, interest, rental income, and royalties, but not wages, Social Security, or most retirement distributions. Gain excluded under the Section 121 home sale exclusion is also excluded from the NIIT, so the surtax only touches taxable gain above the $250,000 or $500,000 limit.15Internal Revenue Service. Questions and Answers on the Net Investment Income Tax A high-income single filer selling long-term stock can face a combined 23.8% federal rate before state tax. Every offset in this article that reduces reportable gain also reduces NIIT exposure.
A large gain also creates a timing problem. The IRS expects tax on it during the year, not the following April. You generally need to make an estimated payment if you expect to owe at least $1,000 after withholding and credits, and your withholding won’t cover at least 90% of this year’s tax or 100% of last year’s (110% if AGI exceeded $150,000).16Internal Revenue Service. Large Gains, Lump Sum Distributions, Etc. You can annualize income and increase the quarterly payment for the period in which the gain hit rather than smoothing it across all four, which helps when a gain lands late in the year.
State Tax Sits on Top
Federal is only part of the bill. Most states tax capital gains as ordinary income, with rates from 0% in no-income-tax states up to roughly 14% at the high end. A few states exempt certain gains or offer partial exclusions, but most treat a capital gain the same as a dollar of salary. Run the state number before deciding whether a particular offset is worth the effort.