If you’ve ever woken up with a tingling arm or achy neck, you’ve experienced the negative effects of sleeping in the wrong position.

The key is alignment: When you sleep with your spine in a neutral position, it reduces the strain on your back and neck. It also helps to sleep on a firm surface.

So which sleep positions should you embrace and which should you avoid? Here’s a rundown, from best to worst.

The ideal sleep position: On your back

The best position to avoid back pain is lying flat on your back.

Even so, many people find it the hardest way to enjoy deep sleep.

For optimal spine alignment, place one pillow underneath your head or neck and another underneath your knees.

If you’re pregnant, however, you should avoid this position because it decreases blood circulation to the heart and baby.

Side sleeping: A solid runner-up

Side sleeping with your legs straight is the second-best position for avoiding back and neck pain.

It’s also a good position for snorers or anyone with sleep apnea because it keeps your airways open.

If you can, stretch your legs out straight and tuck a pillow between your knees to keep your spine in a neutral alignment.

Another type of side sleeping — with your legs bent upwards — is less ideal for your back.

Known as the fetal position, it may be the most popular sleep style, but it promotes an uneven distribution of weight that can cause back pain and sore joints.

Try straightening your body into a relaxed position by untucking your chin and adjusting your knees.

If you’re pregnant, it’s a comfortable way to take the weight from your back.

The worst sleep position: On your stomach

Sleeping on your stomach is the worst position for your spine, according to Raymond J. Hah, MD, a spine surgeon at Keck Medicine of USC and assistant professor of clinical orthopedic surgery at the Keck School of Medicine of USC.

“This position puts the most pressure on your spine’s muscles and joints because it flattens the natural curve of your spine,” he says. “Sleeping on your stomach also forces you to turn your neck, which can cause neck and upper back pain.”

Research shows that there’s a correlation between pain and sleep, so it makes sense to incorporate simple changes in your sleep style that alleviate back pain — and less pain means better sleep.