Xanax isn't a pain medication.   It is used to treat anxiety disorders, panic disorders, and anxiety caused by depression. It may be prescribed in connection with use of an opioid for pain.  Xanax is often used off label for tinnitus.