Topiramate is a medication primarily used to treat epilepsy and prevent migraines. It functions by stabilizing electrical activity in the brain, which helps in reducing seizure frequency and severity. The drug is also known for its off-label uses, including treatment of certain psychiatric disorders and weight loss.