Selling brokerage investments to fund 529 — can I avoid capital gains tax?

We have two kids starting college in the next few years and I want to liquidate part of a taxable brokerage account to fully fund their 529s. The holdings have appreciated a lot — some positions I've held for 6+ years, some I bought last year. My tax software is already showing a big number on Schedule D and I'm wondering if there's a way to structure this to avoid or at least reduce the capital gains tax. I've read vague things about "gifting" shares or timing the sales around income, but nothing concrete. For context we file jointly, one income this year. Is there any legal way to reduce what I owe when selling brokerage investments to fund 529 contributions, or is a capital gain just a capital gain no matter what you do with the proceeds?

34 comments

Does your spouse have any income at all this year, or is it truly zero on their side? That changes one option worth looking at.

Andre K.

Author

Spouse had a small amount of freelance work, maybe a few thousand. Why does that matter?

The 0% long-term capital gains rate applies at certain taxable income levels. The exact threshold depends on your filing year — check the Schedule D instructions or IRS Topic 409 for the current brackets. If your total taxable income falls below the threshold, long-term gains on positions held over a year are taxed at 0%. The freelance income plus any gain you realize all count toward that ceiling, so the number matters.

Worth separating your short-term and long-term positions before you do anything. The ones you bought last year — are they close to the one-year mark? Because short-term gains are taxed as ordinary income, full stop. Long-term gains get preferential rates. The holding period clock for securities starts the day after the trade date you bought and ends on the trade date you sell, not the settlement date.

Andre K.

Author

A few of them are right around the edge — like bought in early summer last year. So I should wait until after that date to sell?

Exactly. If flipping a position from short-term to long-term saves you even a few percentage points of tax on a large gain, waiting a few weeks is almost always worth it. Mark the trade dates from your 1099-B and count from the day after you bought.

I did something similar last year — sold appreciated ETFs to fund a 529 contribution. I uploaded the brokerage statements and Schedule D to taxr.ai and had it walk through each position to show me which were short vs. long-term, estimate the gain on each lot, and flag which ones were close enough to the one-year line that waiting made sense. It didn't change the fundamental rule — a gain is a gain — but seeing it laid out by lot with estimated tax impact helped me decide what to actually sell and when. The 529 contribution itself doesn't reduce federal tax no matter what.

Andre K.

Author

That lot-by-lot breakdown is exactly what I need. My brokerage statement is a wall of positions and I can't easily see which ones are worth waiting on.

Are you using specific identification for cost basis, or is your broker defaulting to FIFO? That choice can significantly change which lots get sold and what gain gets realized.

Andre K.

Author

I honestly don't know — I never changed it from whatever the default is.

Check your broker account settings before you place any sell orders. If you switch to specific identification you can instruct the broker to sell the highest-cost lots first, which minimizes the gain. You'd want to confirm in writing (usually an online instruction at the time of sale) which lots you're selling. Publication 550 on irs.gov covers how specific identification works for securities.

One angle I hadn't considered until I ran my own situation through Taxr — if you have any positions sitting at a loss in the same account, harvesting those losses in the same tax year offsets the gains dollar for dollar on Schedule D before you get to any rate calculation. I had Taxr compare my unrealized gain/loss summary from my brokerage against my draft Schedule D to see how much harvesting would actually move the needle. Ended up selling two losers I'd been ignoring. The wash sale rule is the trap here though: if you buy back substantially identical securities within 30 days before or after the sale at a loss, the loss is disallowed and gets added to the basis of the new shares instead.

Andre K.

Author

I do have a couple positions that are underwater. So if I sell those in the same year, those losses net against my gains on Schedule D first?

Yes. Short-term losses offset short-term gains first, then long-term losses offset long-term gains, and then net losses in one category can offset net gains in the other. If you end up with a net loss overall, there's a cap on how much you can deduct against ordinary income in one year — the Schedule D instructions have the exact figure. Anything over that carries forward.

To be clear on the 529 side: there is no federal deduction for contributing to a 529. Some states give a state income tax deduction, but that's separate from federal. The federal capital gain on the sale is owed regardless of where the proceeds go.

Andre K.

Author

Yeah I figured that out the hard way reading the IRS site. No federal benefit for the contribution itself.

Have you considered whether gifting appreciated shares directly to the 529 is possible? Some 529 plans accept in-kind transfers of securities.

Most 529 plans don't accept in-kind contributions — they require cash. You'd need to check with your specific plan, but don't count on this working. The more common strategy is gifting appreciated shares to a family member in a lower tax bracket who then sells and contributes cash, but that has its own complications including gift tax rules.

Andre K.

Author

I checked and my plan only takes cash. So that avenue is closed.

Does your income vary much year to year? If you have a lower-income year coming — sabbatical, job change, whatever — spreading the sales across two tax years might keep more gains in a lower bracket.

Andre K.

Author

This year is actually lower than usual, which is partly why I was thinking now was the time. Next year should be higher.

The 0% rate on long-term gains is real but the ceiling is lower than people expect once you add in wages, any self-employment income, and the gains themselves. Run the numbers on a draft Schedule D before you sell everything at once. Your tax software should let you model it.

This is the key point. The gain itself pushes your taxable income up, so you might start a sale in the 0% zone and cross into the 15% zone partway through. Staggering sales across December and January of two different tax years is a way some people manage that.

Are any of these holdings in a fund that might also distribute capital gains to you at year end? Some mutual funds do that in November or December and you'd owe tax on the distribution even if you didn't sell.

Andre K.

Author

Good point — a couple are actively managed funds. I should check the fund company's distribution schedule.

I'd flag one thing people sometimes get wrong: even if a loss is real, if you sell a position at a loss and within 30 days before or after the sale you or your spouse buys substantially identical securities — including inside an IRA or Roth IRA — it's still a wash sale. The loss gets disallowed and added to the basis of the new shares. Your 1099-B box 1g will show the disallowed amount for covered securities with the same CUSIP in the same account, but the rule applies even when it's not reported there. Code W in column (f) of Form 8949 is how you flag it.

The IRA piece catches people. You think you harvested a clean loss and then realize you had an automatic reinvestment or a contribution buying the same fund in your IRA within the 30-day window.

What's your expected timeline for actually needing the 529 money — first tuition bill in a year, two years? That changes how aggressive you can be about spreading this across multiple tax years.

Andre K.

Author

First one starts in roughly 18 months, second about three years out. So I have some flexibility on the second kid's portion at least.

To summarize the actual levers here since there are a lot of replies: (1) hold short-term positions past the one-year mark if feasible, (2) use specific identification to sell high-cost lots first, (3) harvest offsetting losses in the same year while watching the wash sale window, (4) check whether your total taxable income keeps you in the 0% long-term rate zone, (5) split sales across tax years if that helps. None of these eliminate capital gains tax on a true gain — they just reduce the amount or rate. The 529 contribution itself is a use of after-tax money federally.

Andre K.

Author

This is the clearest rundown I've gotten. Combining a few of these — especially waiting on the short-term lots and harvesting the losses I have — should move the number meaningfully.

If the total gain is large enough that AMT might become a factor, that's worth modeling too. Usually more relevant for ISO exercises than brokerage sales, but worth a glance at Form 6251 if you have other preference items.

If the numbers involved are substantial — like six figures of gain — it might be worth a session with a CPA before you execute the sales. The lot-selection, timing across years, and loss-harvesting all interact, and a mistake in execution (buying back a harvested position too soon, wrong lot instruction) is hard to undo after the trades settle.

Andre K.

Author

Agreed. I'll model it myself first with the software and then probably run it by a CPA before I pull the trigger on anything over six figures.