sleepbookexplained

The idea, animated · no jargon, no black box

Sleep Efficiency Explained — how a sleep diary turns bedtimes into SE, TST & SOL

A sleep diary is just arithmetic on the times you write down each morning. This page shows that arithmetic happen, one subtraction at a time — how a single night becomes a sleep-efficiency number, why the clock math around midnight is tricky, and how the whole thing can run without ever sending your data anywhere.

Animation: a horizontal bar representing one night in bed fills with jade segments for the time asleep, leaving ink gaps for the time awake, illustrating the sleep-efficiency formula.

Search “sleep diary template” and you get a page you still do the maths on.

If you have insomnia and you’re doing CBT-I, someone has asked you to keep a diary every morning for weeks. The printables you find are static. You write down six or seven times, then you’re supposed to work out — by hand, half-awake — how long you actually slept and how efficient the night was. Every morning. For a fortnight.

The arithmetic isn’t hard. It’s just fiddly, repetitive, and easy to get wrong — especially the part that crosses midnight. That is exactly the kind of job a page can do for you, correctly, every time.

One night, drawn as a strip.

Picture the whole time you spend in bed as a single bar. The parts where you were asleep fill in jade. The parts where you were awake — waiting to drop off, stirring in the night, lying there after the alarm — stay as dark gaps. That strip is the whole idea.

A single night broken into segments A horizontal bar. From left to right: a gap for the pre-sleep wait and time to fall asleep, a long jade asleep block, a small gap for a mid-night awakening, another jade asleep block, then a gap for the minutes lying awake after the final wake-up. pre-sleep + falling asleep awake early rise asleep asleep

Add up the jade and you have total sleep time. Take the whole bar and you have time in bed. Everything else is bookkeeping.

How the number is built — one honest subtraction at a time.

Take a real-ish night: into bed 23:00, lights out 23:15, twenty-five minutes to fall asleep, thirty-five minutes awake in the small hours, final wake 06:10, up at 06:40. Here is every step, nothing hidden.

  1. Time in bed 23:00 → 06:40 = 460 min the whole bar
  2. − pre-sleep wait 23:00 → 23:15 = 15 min in bed, not yet trying
  3. − time to fall asleep 25 min sleep-onset latency (SOL)
  4. − awake mid-night 35 min wake after sleep onset (WASO)
  5. − lying awake after waking 06:10 → 06:40 = 30 min early-rise minutes
  6. Total sleep time 460 − 15 − 25 − 35 − 30 = 355 min the jade, added up

SE = TST 355TIB 460 × 100 = 77.2%

That’s it. Sleep efficiency is the share of your time in bed you actually spent asleep. No threshold is applied, no verdict is passed — it’s a measurement, shown with its own formula so you can check it yourself.

The part that trips everyone up: the clock goes backwards at midnight.

Lights out at 23:15, final wake at 06:30. Subtract the clock numbers and you get a negative. A correct diary notices the later event reads an earlier time, adds a whole day, and gets 435 minutes — not a minus sign.

And when the times genuinely don’t make sense — a final wake-up after you got out of bed, or a “night” longer than any real night — the diary refuses to invent a number. It shows a plain error instead of a nonsense one. The screen can never display a negative sleep time.

Your sleep data never leaves the page — and that’s enforced, not promised.

Sleep is health data. The honest way to keep it private isn’t a privacy policy you have to trust — it’s a page that physically cannot send anything. One line of security policy does that:

Content-Security-Policy:
  default-src 'self';
  connect-src 'none';
connect-src 'none' tells the browser to block every outbound request the page could make — no upload, no analytics, no “phone home”, even by accident.
  • upload to a server blocked
  • analytics / trackers blocked
  • external fonts & scripts blocked
  • save on your device allowed

The diary is stored only in your browser’s local storage. There is no account, no cloud, no share link. Because nothing depends on the network, it also works with no signal at all.

What the diary itself gives you.

The ten-field morning form

The standard sleep-diary items, with inline validation and plain-language errors — a generic implementation of the published fields, not a copied instrument.

Per-night maths, formula shown

SOL, TST and sleep efficiency computed for every night, each printed next to its own formula so nothing is a black box.

The two-week grid

Fourteen nights as stacked strips with 7- and 14-day averages — the exact artifact a clinic asks you to bring.

Trend chart

Sleep efficiency and total sleep time drawn as plain SVG lines across every night. No chart library, no network.

Print, CSV & JSON

A one-page printable handoff for your clinician, a spreadsheet-ready CSV, and a full JSON backup — the only ways data leaves the app.

Nothing it pretends to be

It computes; it never treats. No sleep-restriction schedules, no bedtime prescriptions, no sensor guesses about “true” sleep.

Keep the diary that does the arithmetic.

Enter your mornings, watch the strip and the number appear, print the fortnight when your clinician asks. It stays in your browser — the page can’t send it anywhere.

Open sleepbook →

Free · no account · runs 100% offline