First things first: There are no "good" or "bad" reasons to divorce or to not divorce. Each person must decide for themselves what they prioritize and what works best for their situation.
So, if the fear of having to file for bankruptcy is a major reason you have not filed for divorce, that is a valid fear. It may help to gather some facts (if you have not already) so you can make an educated decision.
Divorce is not designed to punish just one party
If your fear is that you have been, say, a stay-at-home parent with little income and assets and that your high-earning spouse will leave you penniless, know that divorce is not designed to be punitive toward one party. The process aims to leave both parties in decent financial shape, even if there are prenuptial agreements. No matter what your prenup says (if you have one), it is unlikely that a judge will leave you and your children practically on the streets. Resources such as alimony and your share of the assets may help you avoid bankruptcy.
Divorce and bankruptcy can mean a fresh start
However, you and your spouse may both not earn much, so neither one of you will end up with anything much. Filing for bankruptcy can still be helpful, whether it is before or after your divorce. Bankruptcy can erase debts such as credit card bills and medical bills that have been a major stressor in your life and stop creditor harassment.
Also, if your spouse has been the one racking up debts in both of your names, it can be a big relief not to worry about that happening anymore.
What if you have been the excessive spender?
What if you have been the one racking up debts? Could you get in trouble with your spouse by filing for divorce? Meeting with a lawyer can help clarify what all you owe and what the true picture of your marriage and your financial situation looks like. Overall, yes, it can be scary to face the prospect of not having your spouse's income to fall back on, but it is something that many people have worked through successfully.