401k assets are generally protected from creditors under state and federal law in a Chapter 13 bankruptcy--they are usually not part of the bankruptcy estate. Other qualified retirement assets and IRAs are exempt, as well.
A bankruptcy has no effect on a participant's 401k. The Employee Retirement Income Security Act (ERISA) supersedes all other federal or state lawns in this area. Bankruptcy judges understand this; however, creditors and others often claim that you must take a withdrawal when you do not. You can not be forced to withdrawal money for this reason.
A Chapter 13 bankruptcy operates as a repayment plan for a period of three to five years. During this time, the debtor makes payments to a bankruptcy trustee who in turn apportions the funds and pays down the balances owed to the debtor's creditors.