Health & Life Runs locally Ready to use Built-in examples No tracking

Sleep Calculator

Enter a wake-up time to see when to go to bed, or a bedtime to see when to wake up, with an adjustable cycle length and falling-asleep buffer and a 1-to-6 cycle table.

Sleeping whole cycles matters more than counting hours: a cycle runs about 90 minutes, though individuals range from 60 to 120, and waking at the end of one leaves you clearest — being dragged out of deep sleep by an alarm is what produces the fog. This tool works in both directions: give a planned wake-up time and it says when to go to bed, or give a bedtime and it says when to wake, with the cycle length and the falling-asleep buffer adjustable.

On the settings: the falling-asleep buffer defaults to 15 minutes, the time between lying down and sleeping, and should be set to your own habit; adults are usually advised four to six cycles, six to nine hours. Cycle length varies from person to person, and recording how clear-headed you feel on waking over several days is how to calibrate your own.

How to use

  1. Choose the direction: from a wake-up time, or from a bedtime.
  2. Enter the time and, if needed, adjust the cycle length.
  3. Set the falling-asleep buffer to your own habit.
  4. Check the table of one to six cycles and pick a sensible one.

How it works

What a sleep cycle means

Sleep proceeds in roughly 90-minute "cycles," each passing through light sleep, deep sleep and REM in turn. Waking at the end of a cycle (in the light-sleep phase) usually leaves you more alert than being woken during deep sleep — the source of the "wake after a whole number of cycles" advice. Note that 90 minutes is a population average, with 70-120 minutes normal per individual.

How the sleep latency is counted

Falling asleep typically takes 10-20 minutes from getting into bed, and this time isn't counted in the sleep cycle. So "bedtime = wake time - cycles x 90 minutes - sleep latency." The default estimates 15 minutes; if you usually fall asleep within minutes, change it to 5-10, and if you often toss for half an hour or more, make it larger.

Why 5 cycles is recommended

The recommended value is 5 cycles, i.e. 7.5 hours of actual sleep (excluding latency). Adults are advised 7-9 hours, and 5 cycles falls in the middle; 4 cycles is only 6 hours, low long-term; 6 cycles (9 hours) is high for most. The table lists 1-6 cycles so you can pick for the evening.

Calculation basis: one sleep cycle is estimated at the population median of about 90 minutes (individual range 70–120), sleep onset latency defaults to 15 minutes, and the recommended 5 cycles (7.5 hours) matches the 7–9 hours advised for adults. The result is a scheduling guide, not medical advice.

Code example

JavaScript Working backwards to a bedtime

function bedtimes(wakeAt, cycleMin = 90, latencyMin = 15) {
  const wake = new Date(wakeAt).getTime();
  const out = [];
  for (let n = 6; n >= 3; n--) {
    const t = wake - (n * cycleMin + latencyMin) * 60000;
    out.push({ cycles: n, bed: new Date(t) });
  }
  return out;   // bedtimes for 6 down to 3 cycles; pick the 4~6 range
}

Python The same formulas in Python

from datetime import datetime, timedelta

def bedtimes(wake_at, cycle_min=90, latency_min=15):
    wake = datetime.fromisoformat(wake_at)
    return [{"cycles": n,
             "bed": wake - timedelta(minutes=n * cycle_min + latency_min)}
            for n in range(6, 2, -1)]

# 4~6 cycles is the adult recommendation; calibrate the cycle length by how rested you feel

FAQ

Where does the 90-minute sleep cycle come from?

From sleep-staging research: one complete NREM-REM loop averages about 90 minutes (70-120 individually). It's not a hard physiological constant but a convenient approximation for scheduling, so this tool lets you change it to any value from 60-120.

What should I enter for sleep latency?

The time from getting into bed to actually sleeping, generally 10-20 minutes, default 15. Healthy people average about 15; if you often take over 30 minutes, beyond changing the value, watch pre-sleep light, caffeine and schedule regularity.

Why is 5 cycles recommended?

5 cycles = 7.5 hours of actual sleep, in the middle of the 7-9 hour adult recommendation. 4 cycles (6 hours) is low for most adults, and 6 cycles (9 hours) high and often forces too early a bedtime. All tiers are given, so take what fits the night.

Is 6 hours or 7.5 hours better?

All else equal, 7.5 hours (5 cycles) is better. 6 hours (4 cycles) is also a whole number of cycles and may not feel bad to wake from, but chronic short sleep accumulates sleep debt, showing as reduced focus and mood swings — "waking fresh" doesn't mean "slept enough."

My cycle doesn't seem to be 90 minutes — what then?

Change "single cycle length" to your actual value (60-120 minutes). To determine it: over several days, record sleep and wake times at natural waking without an alarm, and average the total sleep divided by the number of cycles; or look at the interval between adjacent REM segments on a wristband's sleep-stage chart.

Why do suggested times sometimes say "previous day" or "next day"?

Because they cross midnight. For example back-solving 5 cycles from a 7:00 wake gives a bedtime of 23:15 the previous day; going forward 1 cycle from a 23:00 bedtime gives 00:45 next day. The label just reminds you not to misread the date; the time itself is unambiguous.

Can this tool replace sleep monitoring?

No. It's a schedule projection based on average cycles, not measuring your actual sleep structure, and can't detect sleep apnea or insomnia. For chronic difficulty falling asleep, early waking or extreme daytime sleepiness, see a sleep specialist rather than adjusting schedule times.

Are the times I enter recorded?

Not uploaded. The projection runs entirely in the browser with no network request; history is written only to local localStorage and clearable in one click.