Though you commonly hear 401k plans referred to as "retirement plans," the tax code doesn't actually require that you be retired to withdraw money from a 401k. Depending on the rules of your specific plan, you may be able to make withdrawals before retirement -- but you might be subject to a stiff tax penalty.
Tax Law vs. Plan Rules
The federal tax code sets broad rules for 401k withdrawals, but individual plans are free to institute their own, stricter rules. For example, the law says a 401k plan can allow a participant to make a penalty-free "hardship" withdrawal in a case of financial need. That doesn't mean your specific plan must allow such a withdrawal; only that it could allow it if it chose to. In general, the law defines the scope of what plans can allow, and plans then set their rules within those limits.
Over Age 59-1/2
Under the tax code, you can begin taking "distributions" -- the Internal Revenue Service's term for withdrawals -- as soon as you turn 59-1/2, regardless of whether you're retired. However, be aware that your plan might not allow you to take distributions if you're still working. Any distributions taken after 59-1/2 are taxed just like regular income -- the same as if the money was wages from a job.
Under Age 59-1/2
If you're not yet 59-1/2, your plan may still allow you to make a withdrawal, though it doesn't have to. Assuming you can take an "early distribution," the amount you take out will be taxed like regular income. In addition, you'll pay a 10-percent tax penalty on the amount of the withdrawal. So if you take out $10,000, you'll pay a $1,000 penalty, plus the income taxes.
Federal tax rules for 401k plans also allow for hardship distributions, which are early withdrawals for people experiencing specific types of "immediate and heavy financial need." As with early withdrawals, a plan may offer hardship withdrawals, but it is not required to. If you can take a hardship distribution, it will be taxed like ordinary income but you will not have to pay the 10-percent penalty. The IRS provides six situations that may qualify for hardship distributions: medical bills, funeral expenses, college costs, buying a home, preventing foreclosure or eviction and repairing damage to a home. You'll have to attest that you don't have any other way to pay these costs, and the amount you can withdraw is limited to your own contributions to the plan -- the money you've put in. You can't take out any of your investment gains.
A 401k plan can also allow participants to borrow money from their accounts. Since you must pay the money back, loans do not count as distributions, so you don't have to pay any tax. If you fail to repay the money according to plan rules, though, the loan will be treated like a distribution, subject to income tax and, if you're under 59-1/2, the 10- percent penalty.