Detox programs are not generally cheap but you might be able to attend one for free or close to free depending on your situation. For example, if you have good insurance then it might be covered entirely, or there might just be a small copay. On the other hand, sometimes the copay is not so small for a few days of medically supervised detox. And in some cases, you can get treatment for free if you have Medicaid.
Even if you have to pay cash, the price of detox is actually a small price to pay if you actually manage to stay clean and sober. Most drug addicts and alcoholics spend thousands of dollars on their addiction over a relatively short period of time. Some will easily spend over ten thousand dollars in a single year on their addiction, so the cost of detox is actually pretty minimal in comparison. The key, of course, is that you actually follow through and change your life. If you leave detox and go right back to using then it is a pretty big waste of time and money. If you stay clean for at least a year or more then it will more than pay for itself as a smart investment.
Learn more about detoxification programs and also about detox treatment.