Xanax does not interact significantly with cocaine. If a person came to the ER with anxiety from cocaine, a Xanax-like medication would likely be given to the person.
But I can't really say it is 'safe' to take Xanax after cocaine. The Xanax is not likely to do anything bad, assuming you take it in a reasonable, therapeutic dose. But cocaine is NEVER a 'safe' medication. People will take cocaine for months or even years without incident, and then the next time they use it develop a fatal arrhythmia. The high profile death of Len Bias was an example of that situation, and the deaths of Belushi or Chris Farley were similar (they combined cocaine with opioids).
The Xanax will reduce the anxiety and agitation caused by cocaine, but will do nothing to reduce the risk of cardiac arrhythmia. I hope you get to treatment soon.
I'm checking into rehab next week but don't want to die before i go. Can I take xanax 3 hours after doing cocaine