ForHosting KIT · Health & fitness

Sleep calculator

Plan sleep in whole 90-minute cycles. To wake at 07:00 after 5 cycles, with 15 minutes to fall asleep, go to bed at 23:15. It also works forward from bedtime to suggest wake times. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Calculation mode
Calculate bedtime
Time
07:00
Sleep cycles
5
Time to fall asleep (minutes)
15
You get
Cycle length (minutes)
90
Suggested times
23:15, 00:45, 02:15, 03:45, 05:15

Each result adds your fall-asleep latency and whole cycles.

Counting back from your alarm

In bedtime mode you enter the time you want to wake up and the calculator works backward. From the wake time it subtracts the minutes you usually need to fall asleep and then whole 90-minute cycles, with one suggestion per cycle. With a 07:00 alarm, 5 cycles and 15 minutes to fall asleep, the bedtimes are 23:15, 00:45, 02:15, 03:45 and 05:15. The list runs from the earliest bedtime, which gives the most sleep, to the latest, so you can pick how much rest to aim for.

Counting forward from bedtime

Wake mode does the opposite: enter the time you go to bed and it adds your fall-asleep minutes plus one, two or more full cycles, listing wake times from the soonest to the latest. Times use the 24-hour clock and roll over midnight cleanly, so a bedtime late in the evening produces wake times the next morning without manual adjustment. You can ask for between 1 and 12 cycles, 5 by default, and set the fall-asleep time to any whole number of minutes.

What time format does it expect?

A 24-hour HH:MM string from 00:00 to 23:59. Times that cross midnight wrap correctly in the output.

How many suggestions do I get?

One per cycle, set by cycles (default 5, allowed 1 to 12). bedtime lists earliest to latest; wake lists soonest to latest.

When should I wake up if I go to bed now?

Use the wake mode and enter the time you go to bed. The calculator adds your minutes to fall asleep plus one, two or more full 90-minute cycles, and lists wake times from the soonest to the latest.

What is the fall-asleep time for?

It is counted before the cycles, because the first cycle only starts once you are asleep. It is 15 minutes by default, and you can set any whole number of minutes, zero included.

What happens when a time crosses midnight?

The calculation rolls over midnight cleanly on a 24-hour clock: with a 07:00 alarm, the first bedtime suggested is 23:15 the evening before, with no adjustment needed on your part.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/dev/sleep-calculator

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/dev/sleep-calculator \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mode":"bedtime","time":"07:00"}'
{
  "mode": "bedtime",
  "time": "07:00"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "dev.sleep_calculator",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Given a target time and a mode, it lists clock times aligned to 90-minute sleep cycles. mode=bedtime returns bedtimes for a wake target; mode=wake returns wake times after a bedtime.

Ninety-minute cycles from an anchor time

The time field is a 24-hour HH:MM clock value that becomes the anchor, converted to minutes since midnight. Times wrap cleanly across midnight using modulo 1440 and are formatted back to zero-padded HH:MM. A sleep cycle is fixed at 90 minutes (returned as cycle_minutes). In mode=bedtime the anchor is your desired wake time and the tool works backward: for each cycle count from cycles down to 1 it computes anchor minus latency_minutes minus n times 90, so with a 07:00 wake, 5 cycles and 15 minutes latency you get bedtimes 23:15, 00:45, 02:15, 03:45 and 05:15. In mode=wake the anchor is your bedtime and it works forward: anchor plus latency_minutes plus n times 90 for n from 1 to cycles.

Cycles, latency and the suggestions list

In bedtime mode the list runs from the earliest (most sleep) to the latest bedtime; in wake mode from the soonest to the latest wake time. cycles defaults to 5 and must be an integer from 1 to 12; it sets how many suggestions come back, one per completed cycle so you can choose how much total sleep to target. latency_minutes defaults to 15 and must be a non-negative integer; it models the time to actually fall asleep and shifts every suggestion, since real rest starts after you drift off, not the moment you lie down. The response echoes mode, the normalized anchor time, cycles, latency_minutes and cycle_minutes alongside the suggestions array.

Validation and deterministic output

Every field is checked before any time math. Note this tool takes the clock time as an input parameter rather than reading the system clock, so it never consults the real time of day and its output depends only on the arguments. The time must match a strict 24-hour pattern (00:00 to 23:59); anything else, including a non-string, throws a typed invalid_input error. A cycles value outside 1..12 or a non-integer, and a negative or non-integer latency_minutes, are rejected the same way, as is a mode other than bedtime or wake and any non-object input.

Planning tonight's bedtime

Enter your alarm time in mode=bedtime to see which bedtimes let you wake at the end of a cycle rather than mid-cycle.

Nap and shift-work timing

Use mode=wake from a chosen lie-down time to find wake targets one to twelve cycles out for naps or rotating shifts.

Sleep and wellness apps

Embed cycle-aligned suggestions in an app or bot via the API, tuning latency_minutes per user for personalized advice.

How long is one cycle?

A fixed 90 minutes, reported in the response as cycle_minutes. Suggestions are spaced one cycle apart.

What does latency_minutes do?

It is the time you take to fall asleep (default 15). It shifts every suggested time so cycles are counted from when you actually drift off.

Is it free and what does the API cost?

The browser widget is free; the API uses prepaid KIT balance from $0.002, and failed tasks are not charged.

Read the full KIT documentation →