A healthy diet with plenty of fresh fruits and vegetables can also help to decrease the frequency of leg cramps. Vitamins and Minerals: Potassium and Magnesium for Muscle Cramps. Additionally, certain vitamins and minerals impact muscle function, particularly potassium and magnesium.