Your 401(k) is a retirement account, and it serves you best in that capacity. But you can save a lot in interest by using a 401(k) loan to pay off credit card debt. With some credit card interest rates as high as 30%, you will pay a much lower interest rate on the loan, and better yet, you will be paying interest to yourself because both principal and interest payments on 401(k) loans go into your 401(k) account.
In most cases, a 401(k) loan should be a last resort to pay off your credit card debt. Depending on your outstanding credit card balances and interest rates, you may benefit from consolidating your debts with a 401(k) loan. But before making the decision, consider whether the opportunity cost is worth it.