How to reduce taxes on long-term capital gains and w-2 income before year end

Trying to figure out what I can still do before December 31st. I have a decent amount of long-term capital gains this year from selling some index fund positions I'd held for over two years, plus my regular salary. When I look at where my income lands, I'm wondering if there's a way to offset some of those gains or at least bring down my taxable income before the year closes. I already maxed my 401k contributions through payroll. I looked at tax-loss harvesting but most of my other positions are still up. I haven't touched my HSA yet. Is there anything else worth looking at on the investment side specifically? I'm not sure how the LTCG rate interacts with my W-2 when it comes to which bracket I actually land in.

37 comments

The interaction between W-2 and long-term capital gains is the key thing here. Your ordinary income (wages) fills the lower brackets first, and your LTCG sits on top of that stack. So the rate that applies to your gains depends on where your total income falls. The specific thresholds are in the Schedule D instructions for the Qualified Dividends and Capital Gain Tax Worksheet—worth running those numbers before year end so you know exactly where you stand.

Sam H.

Author

That's the part that was confusing me. So my W-2 essentially determines how much room I have in the lower LTCG rate bracket before the gains start getting taxed at the higher rate?

Exactly. Run the worksheet or have your software do it. If you're close to a threshold, reducing W-2 taxable income through a traditional IRA or HSA contribution could shift more of your gains into the lower bracket.

Tax-loss harvesting is still worth revisiting even if most positions are up. Look at any positions you hold at a loss in taxable accounts—even small ones. Losses on Schedule D offset gains dollar for dollar. Report them on Form 8949 with the correct box checked (A, B, or C for short-term; D, E, or F for long-term), then they flow to Schedule D. Watch the wash sale rule: if you sell at a loss and rebuy the same fund within 30 days before or after, the loss is disallowed and gets added to the new shares' cost basis instead.

Sam H.

Author

Is the wash sale window really 61 days total—30 before, 30 after, plus the sale date?

Yes, 30 days before and 30 days after the sale date. So if you sell December 15th, you can't buy back a substantially identical security before January 15th without triggering the wash sale rule. You can buy something similar but not substantially identical in the meantime.

HSA contributions are one of the cleanest moves left if you haven't used that limit. Contributions reduce your AGI directly, which lowers your taxable income across the board including the base your LTCG rate calculation runs on. Check your plan's eligibility rules and the contribution limits in the Form 8889 instructions—you can contribute up to the annual limit as long as you were enrolled in a qualifying HDHP.

Does contributing now still count for this tax year even if the HSA custodian processes it in January?

HSA contributions for the current tax year can generally be made up to the tax filing deadline, not just December 31st. So you have more runway than you might think. Confirm with your custodian how they code the contribution year.

I uploaded my brokerage year-end summary and my last pay stub to taxr.ai and it walked through how my W-2 income was stacking against the LTCG thresholds on the Qualified Dividends and Capital Gain Tax Worksheet. It flagged that I was sitting just above the lower rate cutoff and listed which of my losing positions, if harvested, would bring me back under it. That concrete number was what I actually needed to decide whether harvesting was worth the trades. The rule itself is in Publication 550 and the Schedule D instructions, but seeing it mapped to my actual numbers saved a lot of back-and-forth.

Sam H.

Author

Which pub covers the interaction between ordinary income and LTCG rates in plain terms?

Topic 409 on the IRS site covers capital gains and losses including the rate structure. The Schedule D instructions have the actual worksheet. Publication 550 chapter 4 goes deeper if you want the full picture.

Qualified charitable distributions from an IRA won't help you here if your gains are from a taxable brokerage account, but donating appreciated securities directly to a charity is worth knowing about. You avoid recognizing the gain entirely and get a deduction for the fair market value. That's a double benefit if you were planning to give anyway. The holding period has to be more than one year for the full deduction—same threshold as long-term treatment.

Does the deduction show up anywhere on the return or just in the fact that the gain never gets reported?

The gain never hits your return because you never sold the shares—the charity receives them directly. Your charitable deduction goes on Schedule A if you itemize. If you don't itemize it doesn't help the income side, so factor that in.

One thing people skip: check whether you have any capital loss carryforwards from prior years. Those carry forward on Schedule D and offset current-year gains before you even get to this year's transactions. Look at last year's Schedule D line 14 or the Capital Loss Carryover Worksheet in the prior-year Schedule D instructions to find the number.

Sam H.

Author

Didn't realize carryforwards show up that explicitly. I'll check last year's return.

If your gains are still sitting unrealized and you haven't sold yet, you might also just model out whether selling in January instead of December makes sense. Deferring the gain by one day across the year boundary pushes the tax bill to the following year's return. Doesn't reduce what you owe eventually, but changes the cash flow timing.

My situation last year was W-2 plus a chunk of LTCG from selling ETF positions I'd held for about three years. I uploaded both my 1099-B and my W-2 to Taxr and it compared the cost basis on the 1099-B against what I'd actually paid, flagged two lots where the broker had the wrong basis, and drafted the column (g) adjustment entries for Form 8949 so I could correct them before filing. Turned out I had more loss to work with than the 1099-B showed. The rule on correcting basis when it's reported to the IRS is in the Form 8949 instructions—when box A or D is checked, you still enter the broker's basis in column (e) and correct it with an adjustment in column (g).

Sam H.

Author

How common is it for the broker's reported basis to actually be wrong?

More common than you'd expect with older lots, shares acquired through DRIP, or positions transferred between brokers. Covered securities have basis reported to the IRS, so a discrepancy there needs the column (g) adjustment and code B in column (f) on Form 8949—not just a mental note.

Traditional IRA contributions can lower AGI if you're eligible for a deduction, but whether you can deduct depends on whether you or your spouse are covered by a workplace retirement plan and your income level. Since you have a 401k you're already a covered participant, so the deductibility phases out—check the Publication 590-B... actually the deductibility rules are in the Form 1040 instructions and Publication 590-A, not 590-B. Point is, verify eligibility before assuming it reduces your taxable income.

Worth separating: even a nondeductible traditional IRA contribution doesn't reduce AGI, but a Roth conversion strategy is a totally different play and doesn't help with current-year gains either. For reducing taxable income now, the deductible IRA or HSA are the levers.

If you're self-employed on the side in addition to W-2, a SEP-IRA or Solo 401k contribution before year end (or by the filing deadline for SEP) can reduce net self-employment income. But you said salary, so probably not applicable. Just flagging it in case there's any consulting income in the mix.

The net investment income tax is another thing to check. It applies to investment income including LTCG for taxpayers above certain modified AGI thresholds—the thresholds and the form are in the Form 8960 instructions. If you're in that range, reducing AGI hits twice: it lowers both the LTCG bracket calculation and potential NIIT exposure.

Sam H.

Author

Hadn't thought about NIIT at all. So Form 8960 is where that gets calculated?

Yes, Form 8960 is Net Investment Income Tax. If your MAGI is above the threshold it applies on top of your regular income tax on the investment income. The instructions have the phase-in and the specific income items included.

I had a similar stacking question with RSUs vesting on top of LTCG last year. I gave Taxr my W-2 and my brokerage 1099-B and it laid out the complete income stack showing exactly how the RSU ordinary income, LTCG, and my salary interacted on the Qualified Dividends and Capital Gain Tax Worksheet—showed me which bucket each dollar was sitting in. It also caught that my employer had already withheld at supplemental rates on the RSU vest, so my actual liability was different from what I'd estimated. The underlying rules are in Publication 525 and the Schedule D instructions.

Is the RSU income always ordinary, or does it depend on how long you hold the shares after vesting?

The income at vest is always ordinary—the fair market value on the vest date minus anything you paid goes on your W-2 as wages. Any gain or loss after that point, when you eventually sell the shares, is capital and the holding period starts the day after vest. So yes, holding longer after vest can convert future gain to long-term, but the vest income itself is always ordinary.

Bunching itemized deductions into this year if you're on the edge of the standard deduction is another lever. State income taxes (subject to the SALT cap), mortgage interest, and charitable contributions can be front-loaded. Getting above the standard deduction threshold means every additional dollar of deductions is actually working, which flows through to lower AGI-adjacent calculations.

Worth clarifying something from earlier in the thread: the wash sale rule applies to losses, not gains. Selling a winner before year end has no wash sale issue—you can immediately rebuy. The 30-day window only matters when you're selling at a loss and want to keep the position.

Good clarification. And the disallowed loss doesn't disappear—it gets added to the cost basis of the replacement shares, which defers but doesn't eliminate it. That's in Publication 550.

If you end up with more capital losses than gains after harvesting, the excess offsets ordinary income up to the limit set by Schedule D and the Topic 409 rules, with the rest carrying forward. So don't be afraid to harvest more loss than you have gain—the extra doesn't go to waste.

Sam H.

Author

So any losses above gains carry forward indefinitely rather than expiring?

Correct, they carry forward to future years without expiring. The Capital Loss Carryover Worksheet in the Schedule D instructions or Publication 550 is how you figure the amount that carries. The deduction against ordinary income in any one year is capped—check Topic 409 for the specific limit for your filing status.

Year-end is also a good time to check for any mutual fund distributions coming before December 31st. Funds declare capital gain distributions in December and you'll owe tax on them even if you just bought the fund. Some fund families post estimated distribution dates and amounts on their sites. If a large distribution is coming you might weigh whether buying in before that date makes sense.