It's not hard to imagine: A financial crisis suddenly erupts and you need a significant chunk of change to pay for an unexpected home repair or just to pay the mortgage after you unexpectedly lose your job. What do you do? Well, you might be tempted to borrow money from your 401(k). Think twice or thrice before doing so, though.

Borrowing from a 401(k) is something that many people have considered and many people have done. According to a 2015 report  from Fidelity Investments, which administers many of 401(k) accounts, about 22% of employees had outstanding 401(k) loans (with that level representing the lowest level in five years). Some of those folks may have had little choice, but many could have and should have avoided taking out that loan.

Why you shouldn't borrow money from your 401(k)

A key reason to not borrow from your 401(k) is because it will hurt your retirement. A 401(k) is a retirement account, after all, collecting contributed dollars over time and letting them grow for your future needs in a tax-advantaged fashion. Take money out of it prematurely, though, and what you withdraw will no longer be working for you.

Imagine, for example, that you withdraw $12,000 from your 401(k) and you pay it back in five years. If it had stayed in your account and had been invested in the stock market, earning, say, 10% annually on average, then it would have grown to about $19,000. So you would lose out on $7,000 of growth. Also, in the following years, that $19,000 would have kept growing. Removing a chunk of your 401(k) will deliver a real setback to your savings -- especially if you borrow an extra large sum for an extra long period, such as for a down payment on a house.

Another drawback is that if you can't repay the loan, it will be considered an early withdrawal and may trigger a 10% penalty -- if you're younger than 59 1/2. A 10% penalty on a $12,000 loan is $1,200, a rather significant sum.

Borrowing from a 401(k) will probably also shrink your paycheck, as repayments are often automatically deducted from it. It's worth crunching some numbers to see how much less you'll be taking home each pay period, and whether you can get by on that. Some people, facing smaller paychecks, might cut back on the 401(k) contributions made from their paychecks, further hurting their retirement savings. (Many plans have terms that prohibit you from making new contributions to your account until the loan is paid off, too, further hurting your savings.)

Finally, if you lose your job, you'll have to pay off that loan pronto, or it will be considered defaulted. Then you'll get taxed on it and perhaps face an early withdrawal penalty, too. Before borrowing from a 401(k), be pretty sure you won't be losing or changing your job. Meanwhile, if a more exciting job comes along and you want to take it, you may not be able to. Being in such a situation can limit your possibilities.

When it can be OK to borrow from a 401(k)

Of course, it might sometimes make sense to borrow from a 401(k). If you simply have no other option, go for it. If it's just better than other options, such as if your bank will charge you much more to borrow, then it might make some sense. If you know the loan will be a short-term one and you're quite sure of your ability to repay it, it shouldn't be too damaging.

Remember, though, that many financial crises can be eased or resolved in some creative ways. Before you borrow against a 401(k) in order to pay utility bills or pay off credit card debt, try calling your creditors and explaining your situation. See if some arrangement can be made to help you get your finances in order again.

If you do end up deciding to borrow from a 401(k), be sure to pay it back as soon as you can. Failing to do so can damage your future financial well-being.