Xanax is a medication that is used to treat anxiety. It belongs to the class of drugs called benzodiazepines. It is also sometimes used to treat panic attacks and sleep problems. Xanax works by blocking the action of chemicals in the brain that can cause anxiety