To prevent muscle cramps, try these tips: 1  Stretch regularly before and after exercising to increase your flexibility. 2  Do workouts that match your level of physical fitness. 3  Eat a well-balanced diet with plenty of potassium-rich fruits and vegetables.  Stay well-hydrated before, during, and after exercise.