Saving for retirement is only half the battle -- you also have to pick the right accounts. A 401(k) is specifically designed for retirement savings, whereas a health savings account (HSA) is intended for medical savings, though it has appealing perks for retirement savers as well. Below, we'll look at some of the pros and cons of each type of account so you can decide which one is best for you.

How a 401(k) works

A 401(k) is a common type of employer-sponsored retirement plan. You elect to defer a portion of each paycheck, and your employer transfers these funds automatically into your 401(k). In some cases your company may even match your contributions.

Notebook page headed "Retirement planning" next to calculator, glasses, and money.

Image source: Getty Images.

In 2021, you may contribute up to $19,500 to a 401(k), or $26,000 if you're 50 or older. Often you're limited to only a few investment options preselected by your employer. Sometimes the 401(k) may incur high fees that eat into your profits, though this isn't always the case.

Most 401(k)s are tax-deferred, which means your contributions reduce your taxable income for the year, but you pay income taxes on your withdrawals later. Roth 401(k)s are becoming more popular, and these work the opposite way -- you pay taxes on your contributions, but then you get tax-free withdrawals.

You may borrow money from your 401(k) and roll your account over into a new 401(k) or an IRA if your plan allows it. Some plans permit rollovers only if you're no longer employed at the company. While you can't directly transfer funds from a 401(k) to an HSA, you can do so indirectly by first transferring your 401(k) funds to an IRA and from there moving them to an HSA. 

You're allowed to roll over only up to your annual HSA limit, discussed below, and you can do an IRA-to-HSA rollover only one time in your life. You must be eligible for an HSA at the time of the rollover and remain eligible for at least 12 months afterward. 

How an HSA works

Health savings accounts (HSAs) were primarily designed to help people cover their medical expenses, but they're well suited for retirement savings, too. To open an HSA, you must have a high-deductible health einsurance plan -- one with a deductible of $1,400 or more for an individual or $2,800 or more for a family for 2021.

Some employers offer HSAs as an employee benefit. In this case the account works similarly to your 401(k): You elect to defer a percentage of your income, which comes directly out of your paycheck. If your company doesn't offer an HSA, but you have a qualifying health plan, you can still open and contribute to an HSA yourself.

In 2021, individuals may contribute up to $3,600, whereas families may contribute up to $7,200. Adults 55 and older may make an extra $1,000 in catch-up contributions. Some companies even offer an HSA match, but these are less common than 401(k) matches.

A basic HSA is essentially like a savings account. You put money in, and it earns a small amount of interest annually. However, an increasing number of HSAs enable you to invest your funds just like 401(k)s. This can help you grow your savings much faster. If you open an HSA on your own, you'll have greater control over your investment options and how much you're paying in fees.

HSA contributions reduce your taxable income for the year, just like tax-deferred 401(k) contributions. But if you use the money for medical expenses, you don't pay taxes on your withdrawals at all. You can also make nonmedical withdrawals, but you'll pay a 20% penalty plus taxes if you do so before age 65. After 65, nonmedical withdrawals carry no penalty, but you still owe taxes on them. 

You cannot borrow money from an HSA or transfer it to any account other than another HSA. And while you're allowed to continue using your HSA funds after you no longer have a qualifying health insurance plan, you may no longer make new contributions to the account.

You don't have to choose

Great news: It's possible to contribute to both a 401(k) and an HSA in the same year, but it's best to favor one over the other. If you max one out, you can switch to the other type of account. But where should you start?

If you're getting a company 401(k) match, you should definitely contribute at least enough to your 401(k) to get the full match before putting money anywhere else.

Also consider how you intend to use the funds. If you want money you can tap at any time for medical emergencies, an HSA is a better choice; you can make hardship withdrawals from a 401(k) for medical expenses, but you'll have to pay taxes on them. On the other hand, if you're just saving for retirement or you want the freedom to transfer your funds to an IRA later, a 401(k) could be a better choice.

Finally, consider which account will give you the most tax benefits. An HSA is taxed in essentially the same way as a 401(k), except it also includes tax-free medical withdrawals -- in that sense the HSA wins. But if you believe paying taxes up front with a Roth 401(k) will save you more money overall than paying taxes later in retirement, you may prefer to start with your Roth 401(k) and switch to an HSA after you've maxed out your 401(k).

Of course, your circumstances might limit you to one account or another. If your company doesn't offer both types, each offers great benefits.

Both accounts have their pros and cons, but everyone's situation is different and yours could vary from year to year. By reviewing the information above, you should be able to determine which makes the most sense for you right now.