The average adult requires between seven and eight hours of sleep a night, according to the National Institute of Health.
So it's no surprise that staying awake all night isn't healthy, but there's more to it than that.
An all-nighter actually alters the type of sleep our brains get.
Traditionally, sleep starts with a period of non-REM (rapid eye movement) sleep that consists of three phases: stages 1, 2, and 3.
Of the three, stage 3 is the most important for recovering and feeling rejuvenated the next morning. It's also the phase that's most affected by all-nighters because it's when slow-wave sleep sets in.
Slow-wave sleep and REM sleep are the two sleep stages where you're likely to dream as well as store memories, which is important for learning new skills or remembering where you left the house keys the night before.
Pulling an all-nighter deprives the brain of these two critical sleep stages, and puts you in what experts call "sleep debt."
"In the setting of ... an acute sleep debt ... there's different bankers you're going to have to pay back," Timothy Morgenthaler, a Mayo Clinic professor of medicine and the former president of the American Academy of Sleep Medicine, told Business Insider. "There's the REM banker and the slow-wave sleep banker, and the first one you have to pay back is the slow wave sleep banker."
Normally, slow-wave sleep comprises about a quarter of a normal night's slumber — but a night that follows an all-nighter is not normal. By the time your head hits the pillow, you've wracked up a pretty significant sleep debt, and your sleep pattern will show it.
"People tend to get a little bit more slow wave sleep when they're recovering from an acute sleep loss," Morgenthaler said. "The result is that when your boyfriend [for example] has an all night shift and he falls asleep on the couch, and then you wake him up to go to bed he has no clue where he's at," Morgenthaler said.
This confusion is a direct consequence of what experts call sleep inertia, which is also responsible for the grogginess you sometimes feel immediately after waking up.
Normally, the grogginess from sleep inertia lasts no more than 30 minutes after waking, but people who wake up out of slow-wave sleep tend to have more sleep inertia, which can take up to a few hours to completely diminish, Morgenthatler said.
Therefore, the effects of an all-nighter might stick with you even after you've gotten some well-needed rest.