A tax shelter is a way to reduce tax liability. The term is often used negatively, but the Internal Revenue Service (IRS) provides widely available, completely legal ways to reduce your tax bill. You’d be foolish not to set yourself up to benefit from them.

Tax-advantaged retirement plans such as 401(k)s and IRAs (Traditional or Roth) are considered tax shelters because they allow individuals either to contribute pretax dollars, get tax-deferred growth on their investments and pay tax on distributions in retirement—or contribute post-tax dollars, get tax-deferred growth and take tax-free distributions in retirement.

Traditional IRAs and 401(k)s offer the first type of benefits—tax deductions (if you qualify) and tax-deferred growth. Which is better as a tax shelter?

How a Traditional IRA Acts as a Tax Shelter

Traditional IRAs let you contribute pretax dollars, but there are income limits if you have a retirement plan at work. If your filing status is single or head of household and your modified adjusted gross income (MAGI) is below $62,000, you can contribute up to $5,500 ($6,500 if you are age 50 or older) pretax in 2017; if your MAGI is between $62,000 and $72,000, you can make a partially deductible contribution.

For married couples filing jointly where either spouse is covered by a workplace retirement plan, the income limit is $99,000 for a fully deductible $5,500 contribution and $119,000 for a partially deductible contribution. In addition, individuals older than 50 can make catch-up contributions of $1,000 (subject to MAGI limits). Limits are always subject to how much income you earn; you can contribute the lesser of your earned income for the year or IRA limits. Investments within your traditional IRA grow tax deferred until you retire, at which point all distributions are subject to ordinary income taxes.

Traditional IRAs require you to take annual distributions called required minimum distributions (RMDs) starting at age 70½, even if you’re still working. If you don’t withdraw enough according to the IRS’s RMD formula, you’ll pay a tax penalty of 50 percent of the amount you were supposed to withdraw but didn’t.

It’s possible to make nondeductible contributions to a Traditional IRA, also called “after-tax contributions”. Why would you want to do that?

Why would you make nondeductible contributions to a Traditional IRA? Here are four common reasons.

  • You’ve maxed out your 401(k) contributions and your income is too high to contribute to a Roth IRA.
  • You can’t make deductible contributions, thanks to your or your spouse’s workplace retirement plan.
  • Your investments will still grow tax deferred—which means even nondeductible contributions to a Traditional IRA may be more profitable than keeping money in a non-tax-advantaged account.
  • You want to contribute to a Roth IRA through the “backdoor” strategy.

In addition, you can withdraw nondeductible contributions (but not earnings on those contributions) at any time without triggering taxes or penalties. That’s not true for deductible contributions.

Another tax benefit of a Traditional IRA is that it allows spousal contributions as long as you file a joint tax return. If one spouse does not work or does not earn enough to max out IRA contributions, the higher-earning spouse can contribute on the lower-earning spouse’s behalf. However, another limitation of the Traditional IRA is that you can no longer contribute once you reach age 70½, even if you’re still working.

That being said, using a tax-minimizing investment strategy in a taxable account could work out better in the long run if your long-term capital gains tax rate ends up being lower than your income tax rate in retirement. There’s no income limit on nondeductible contributions.

How a 401(k) Acts as a Tax Shelter

A 401(k), like a Traditional IRA, allows you to contribute pretax dollars, and your investment gains are tax deferred. Also like a Traditional IRA, when you take distributions in retirement they are taxed as ordinary income.

Unlike Traditional IRAs, 401(k)s allow for employer contributions as well as a company match. Let’s say your company contributes 5 percent of your salary and also matches your salary-deferral contributions to the plan up to 5 percent. If your salary is $50,000 and you contribute 5 percent, or $2,500, per year, and your company kicks in another $2,500 employer contribution plus a $2,500 employer match, you’re getting an extra 10 percent of your salary per year to save toward your retirement.

Traditional IRAs don’t have this option, and $6,500 is the most you can contribute, even at age 50+. By contrast, a 401(k) plan allows for $18,000 in employee salary deferral contributions, plus an additional $6,000 per year in catch-up contributions for those older than 50. That means you can sock away $18,000 ($24,000 with catch-up contributions), plus any employer contributions and any employer match.

In fact, the total contribution limit to a 401(k) is a whopping $54,000 for 2017, which means your very generous employer could contribute up to $36,000 on your behalf. Furthermore, individuals can make fully tax-deductible contributions to a 401(k) no matter how high their income, whereas a traditional IRA closes off fully deductible contributions to taxpayers who pass certain income thresholds.

One big disadvantage of 401(k) plans is that their investment options are limited. Sometimes those investment options are just as good as what you could buy on your own through a Traditional IRA; other times they underperform or have higher fees than necessary.

If your 401(k) has subpar investment options, it might make sense to invest only as much as it takes to get your full employer match (if any), then max out your Traditional or Roth IRA. Only after you meet that goal should you resume contributing to your 401(k). Even with subpar investment options and high fees, though, the tax savings might make investing through a 401(k) better than using a non-tax-advantaged account. It depends on just how bad the investment choices and fees are.

What about distribution age? Like Traditional IRAs, 401(k) plans have RMDs each year starting at age 70½, but you don’t have to take them from your company’s 401(k) if you’re still working there. (If you have money in a 401(k) from a previous employer, you would have to take an RMD from that plan, though. You may be able to avoid this by moving your 401(k) money from the previous plan to your current one, if your company permits this.)

The “set it and forget it” nature of 401(k) contributions, which come out of your paycheck automatically, might make the 401(k) an automatically superior tax shelter for people who aren’t good about making regular retirement contributions on their own. That being said, it’s not difficult to set up regular automatic withdrawals from a bank account to a Traditional IRA.

And the Winner Is…

So what is the answer to our titular question? The 401(k) is the clear winner. It has substantially higher contribution limits, no income phaseouts on the full deductibility of contributions, and lets you postpone RMDs if you’re still working at age 70½.

Tax shelters aren’t just for the wealthy, and they’re not illegal. Use these retirement accounts to your advantage.

Compare Popular IRA Providers

Provider Fidelity Investments Merrill Edge
E*Trade
Name Fidelity Roth IRA Merrill Edge IRA E*Trade IRA
Description Get a range of investment choices, tax advantages and 1:1 help with a Fidelity Roth IRA Learn More Get up to $600 when you invest in a new Merrill Edge IRA. Plus one-on-one guidance, actionable insights and easy-to-use tools. Learn More Invest for retirement at E*TRADE. Learn More