Using the Tax Code as Designed
Tax optimization isn't evasion or avoidance — it's using the rules Congress wrote to incentivize saving, investing, and healthcare spending. The tax code has dozens of provisions designed to reward specific financial behaviors: contributing to retirement accounts, holding investments long-term, saving for medical expenses, giving to charity. Most people leave money on the table because they don't know these provisions exist or don't realize how they interact.
The goal isn't to pay zero taxes — it's to avoid paying more than you owe. Every dollar you keep through legal tax optimization is a dollar you can invest, save, or spend on things you value.
Myth: "Tax optimization is only for the wealthy. Regular people just take the standard deduction and move on."
✓ Reality: The most powerful tax optimization strategies — contributing to a 401(k), using a Roth individual retirement account (IRA), maxing out a Health Savings Account (HSA) — are available to anyone with earned income and the right account types. A household earning $80,000 that contributes $23,000 to a 401(k) and $4,150 to an HSA reduces their taxable income by $27,150. At a 22% marginal rate, that's nearly $6,000 in tax savings. No accountant required — just knowing which accounts to use and in what order.
Tax-Advantaged Account Stacking
The order you fill accounts matters. Each account type has contribution limits and different tax treatment. A common stacking order:
- 401(k) up to the employer match. This is free money — a 50% match on 6% of your salary is a guaranteed 50% return. No investment beats it.
- Roth IRA. Contributions come from after-tax dollars, but all growth and withdrawals in retirement are tax-free. The 2024 limit is $7,000 ($8,000 if you're 50 or older). Income limits apply.
- HSA (if you have a high-deductible health plan). Triple tax advantage — more on this below. The 2024 limit is $4,150 for individuals, $8,300 for families.
- Back to the 401(k). Max out the remaining 401(k) space up to the $23,000 limit ($30,500 if 50+).
- Mega backdoor Roth. Some 401(k) plans allow after-tax contributions beyond the $23,000 limit, which can be converted to Roth. The total 401(k) limit including employer contributions is $69,000 in 2024. Not all plans offer this — check with your plan administrator.
Sam earns $95,000. Sam's employer matches 50% of 401(k) contributions up to 6% of salary. Sam contributes 6% ($5,700) to get the full $2,850 match, then puts $7,000 into a Roth IRA, then $4,150 into an HSA, then increases 401(k) contributions to the $23,000 max. Total tax-advantaged savings: $34,150 per year. The 401(k) and HSA contributions reduce Sam's taxable income by $27,150. At a 22% marginal rate, that's roughly $5,970 in tax savings — money Sam keeps instead of sending to the IRS.
The HSA: A Uniquely Powerful Account
Triple tax advantage. A Health Savings Account (HSA) is the only account in the tax code with three tax benefits: (1) contributions are tax-deductible, (2) the money grows tax-free, and (3) withdrawals for qualified medical expenses are tax-free. A 401(k) gives you #1 and #2 but not #3 — you pay income tax on withdrawals. A Roth IRA gives you #2 and #3 but not #1 — contributions aren't deductible. Only the HSA offers all three.
To contribute to an HSA, you need to be enrolled in a high-deductible health plan (HDHP). Not everyone has access to one, but if you do and you're generally healthy, the HSA can be a powerful long-term savings vehicle.
The secret strategy: invest your HSA and pay medical bills out of pocket. Most people treat the HSA like a checking account — contribute, then spend on doctor visits. But if you can afford to pay current medical expenses out of pocket, you can invest the HSA money and let it grow tax-free for decades. You can reimburse yourself for medical expenses at any time — there's no deadline. Save your receipts, let the money compound, and withdraw tax-free years later.
After age 65, the HSA functions like a Traditional IRA for non-medical expenses: withdrawals are taxed as ordinary income but there's no penalty. Medical withdrawals remain tax-free at any age.
Tax-Loss Harvesting
Tax-loss harvesting. When an investment in your taxable brokerage account drops below what you paid for it, you can sell it to "realize" the loss. That loss offsets capital gains from other investments, reducing your tax bill. If your losses exceed your gains, you can deduct up to $3,000 of the excess against ordinary income each year, carrying forward any remainder to future years.
After selling, you can reinvest in a similar — but not identical — fund to maintain your portfolio allocation. For example, sell a total U.S. stock market fund at a loss and buy an S&P 500 fund. Both give you broad U.S. stock exposure, but they're different enough to avoid the wash-sale rule.
The wash-sale rule: The Internal Revenue Service (IRS) won't allow the loss deduction if you buy the same or a "substantially identical" security within 30 days before or after the sale. This 61-day window (30 days before + sale day + 30 days after) is the key constraint. Buying a different fund that tracks a different index is generally safe.
Alex bought $10,000 of a total stock market index fund. After a market downturn, it's worth $7,500 — a $2,500 unrealized loss. Alex sells and immediately buys $7,500 of an S&P 500 index fund (different fund, similar exposure). Alex now has a $2,500 realized capital loss. If Alex also sold another investment this year for a $4,000 gain, the $2,500 loss offsets part of it — Alex only owes capital gains tax on $1,500 instead of $4,000. At a 15% long-term capital gains rate, that's $375 saved.
Open the Tax Bracket Calculator and enter your income. Notice your marginal tax rate — that's the rate at which additional income (or capital gains taxed as income) is taxed. Now imagine reducing your taxable income by $5,000 through 401(k) contributions. How much would that save at your marginal rate?
Capital Gains: Short-Term vs Long-Term
When you sell an investment for more than you paid, the profit is a capital gain. How much tax you owe depends entirely on how long you held the investment:
- Short-term capital gains (held ≤ 1 year): taxed at your ordinary income tax rate — up to 37%.
- Long-term capital gains (held > 1 year): taxed at preferential rates of 0%, 15%, or 20%, depending on your income.
The difference is dramatic. If you're in the 24% income tax bracket and sell an investment for a $10,000 gain: selling after 11 months costs $2,400 in tax (short-term, taxed as income). Selling after 13 months costs $1,500 (long-term, 15% rate). Same gain, $900 less in tax — just for waiting two extra months.
This is why buy-and-hold investing is tax-efficient by default. Every time you sell and rebuy, you trigger a taxable event. Investors who trade frequently pay more in taxes, which drags on returns over time.
Asset Location: The Right Investment in the Right Account
Asset allocation is what you invest in (60% stocks, 40% bonds). Asset location is which account holds each investment. The goal: put tax-inefficient investments in tax-sheltered accounts, and tax-efficient investments in taxable accounts.
Tax-inefficient investments (better in 401(k) / Traditional IRA):
- Bonds (interest taxed as ordinary income)
- Real estate investment trusts (REITs) — dividends taxed as ordinary income
- Actively managed funds with high turnover (frequent taxable distributions)
Tax-efficient investments (fine in taxable brokerage):
- Broad index funds (low turnover, few taxable distributions)
- Stocks you plan to hold long-term (deferred gains, qualified dividends)
- Tax-managed funds (designed to minimize taxable events)
Roth accounts: Since Roth withdrawals are tax-free, hold your highest-growth investments here — you want the biggest gains in the account where they'll never be taxed.
Charitable Giving Strategies
If you donate to charity, how you give can be as important as how much you give:
Donate appreciated stock directly. If you own stock that has gone up significantly, donating it directly to a charity (instead of selling it first and donating cash) lets you avoid capital gains tax entirely while still deducting the full market value. You paid $3,000 for stock now worth $10,000? Donate the stock: you deduct $10,000 and pay zero capital gains tax on the $7,000 gain. Sell first, then donate: you owe $1,050 in tax (15% of $7,000) and can only donate $8,950.
Donor-advised funds (DAFs). A DAF lets you make a large charitable contribution in one year (getting the tax deduction now), then distribute the money to charities over time. This is useful if your charitable giving in a single year wouldn't exceed the standard deduction, but a "bunched" contribution in one year would.
Standard Deduction vs Itemizing
The standard deduction for 2024 is $14,600 for single filers and $29,200 for married filing jointly. You only benefit from itemizing deductions (mortgage interest, state and local taxes, charitable contributions) if your total itemized deductions exceed the standard deduction.
Since the 2017 Tax Cuts and Jobs Act roughly doubled the standard deduction, about 90% of filers take the standard deduction. Itemizing makes sense when you have a combination of large mortgage interest payments, high state and local taxes (capped at $10,000), and significant charitable contributions. For most people, the standard deduction is the better deal — and it's simpler.
Open the Roth vs Traditional Calculator. Compare the outcomes with your current income and expected retirement income. If you expect to be in a lower tax bracket in retirement, Traditional (tax-deferred) contributions save more. If you expect your tax rate to stay the same or go up, Roth (tax-free withdrawals) wins. Most people benefit from having both types for tax diversification.
- Stack tax-advantaged accounts in order: 401(k) match → Roth IRA → HSA → max 401(k) → mega backdoor Roth (if available).
- The HSA is the only account with a triple tax advantage — deductible contributions, tax-free growth, tax-free medical withdrawals. Invest it and let it compound.
- Tax-loss harvesting turns paper losses into real tax savings. Sell the losing investment, buy a similar (not identical) fund, and deduct the loss.
- Hold investments for more than one year to qualify for long-term capital gains rates (0%, 15%, or 20%) instead of ordinary income rates (up to 37%).
- Asset location — putting the right investments in the right accounts — adds after-tax returns without changing your risk.
- Donate appreciated stock directly to charity to avoid capital gains tax while deducting the full value.