Sleep Balance
{{ debt_readable }}
Across {{ dayCount }} night(s)
Need {{ formatFixed(sleepNeedValue, 2) }} h/night Avg {{ formatFixed(avg_hours, 2) }} h Gross {{ formatFixed(gross_deficit, 2) }} h Credit {{ formatFixed(oversleep_credit, 2) }} h {{ catchup_days }} day plan Round {{ roundingBadgeText }} Cap {{ deficitCapBadge }} {{ creditModeBadge }}
h/night
Recent nights
h
h
min
h
h
Metric Value Copy
Nights {{ dayCount }}
Sleep need {{ formatFixed(sleepNeedValue, 2) }} h/night
Total sleep needed {{ formatFixed(sleepNeedValue * dayCount, 2) }} h
Total slept (rounded) {{ formatFixed(total_slept, 2) }} h
Average per night {{ formatFixed(avg_hours, 2) }} h
Gross deficit {{ formatFixed(gross_deficit, 2) }} h
Oversleep credit applied {{ formatFixed(oversleep_credit, 2) }} h
Net sleep debt {{ formatFixed(net_debt, 2) }} h ({{ debt_readable }})
Deficit cap {{ deficitCapDescription }}
Rounding rule {{ roundingDescription }}
Credit mode {{ creditModeDescription }}
Max extra per day {{ formatFixed(maxExtraValue, 2) }} h
Nap allowance {{ formatFixed(napValue, 2) }} h
Catch-up capacity per day {{ formatFixed(perDayRecovery, 2) }} h
Catch-up days (est.) {{ catchup_days }}
Night Slept (h) Need (h) Deficit (h) Credit used (h) Cum. debt (h) Copy
{{ r.label }} {{ formatFixed(r.slept, 2) }} {{ formatFixed(r.need, 2) }} {{ formatFixed(r.deficit, 2) }} {{ formatFixed(r.creditApplied, 2) }} {{ formatFixed(r.cumDebt, 2) }}
Day Night extra (h) Nap extra (h) Remaining debt (h) Copy
{{ r.day }} {{ formatFixed(r.nightExtra, 2) }} {{ formatFixed(r.napExtra, 2) }} {{ formatFixed(r.remaining, 2) }}

Chart uses cumulative debt after each night using the rounding, cap, and credit settings above.


                

Enter your nightly log to generate sleep debt metrics, charts, and exports.

Introduction:

Sleep debt is the running gap between the sleep your body needs and the sleep you actually get across recent nights. That makes a simple weekly sleep debt tracker useful for seeing patterns and deciding how to adjust.

You provide a nightly target and a short log of recent nights, then read a clear total with averages and a day count. A seven or fourteen night view shows how small changes add up over time and points to a practical next step.

A quick example helps. With a target of 8 hours, a 6 hour night followed by a 9 hour night still leaves a balance, so you know whether to add time tonight or plan naps.

Numbers can be rounded to consistent minute blocks for cleaner comparisons, and a nightly cap prevents one extreme from dominating the total. You may also let surplus nights reduce what you owe so the balance reflects steadier habits.

Treat results as planning guidance, not medical advice. This tool provides informational estimates and does not substitute professional advice.

Technical Details:

The calculator observes nightly sleep duration and a personal sleep need, then summarizes the difference across a fixed horizon. It computes a per‑night deficit, applies an optional cap, optionally applies credit from surplus nights, and reports the cumulative balance at the most recent night.

Gross deficit is the sum of nightly shortfalls after capping. Oversleep credit is the portion of surplus applied to reduce the running balance. Net sleep debt is the final cumulative value after all nights in scope. A simple catch‑up estimate divides the balance by planned extra time per day from longer nights and optional naps.

Comparability depends on consistent horizon and rounding. Rounding is applied to nightly entries before any other step. Turning credit on or off and changing the nightly cap will change both the totals and the shape of the debt curve.

piraw = xih pi = { m· round ( piraw·60 m ) 60 if m > 0 piraw if m = 0 } di = min ( max(0,Hpi),C) si = max(0,si−1+dici), s0=0 ci = { min( max(0,piH), si−1+di ) if credit on 0 if credit off } D=sN, G=di, A=ci r=X+Y, days= { ceil(Dr) if D>0 and r>0 0 otherwise }
Symbols and units used
Symbol Meaning Unit/Datatype Source
NHorizon nightsintegerInput
xiRaw nightly sleephoursInput
mRounding blockminutesInput
piRounded nightly sleephoursDerived
HSleep need per nighthoursInput
CNightly deficit caphoursInput
diNightly deficithoursDerived
ciCredit appliedhoursDerived
siCumulative debthoursDerived
GGross deficithoursDerived
AOversleep credit sumhoursDerived
DNet sleep debthoursDerived
XPlanned extra at nighthours/dayInput
YPlanned nap timehours/dayInput
rCatch‑up capacityhours/dayDerived
Worked example
Inputs: N=3, H=8.0 h, m=0, C=2.0 h, credit on Oldest→recent nights: 6.0, 9.0, 7.0 h d1=min(2.0,2.0)=2.0 h, c1=0, s1=2.0 d2=0, c2=min(1.0,2.0)=1.0, s2=1.0 d3=1.0, c3=0, s3=2.0 h G=3.0 h, A=1.0 h, D=2.0 h r=1.5+0.5=2.0 h/day, days=ceil(2.02.0)=1

Interpretation: a 2 h balance clears with one day of 2 h planned recovery.

Units, precision & rounding policy

  • Inputs are hours with a decimal point; minute rounding is applied before analysis.
  • Rounding uses standard half‑up behavior from the platform’s round function.
  • Displayed values commonly show two decimals; readable “h m” is also provided.

Validation & bounds

Input validation and bounds
Field Type Min Max Step/Pattern Notes
Horizonselect7147 or 14Fixed choices
Sleep neednumber4120.1Sanitized to non‑negative in code
Nightly entriesnumber0240.1Decimals allowed; rounded if enabled
Nightly deficit capnumber080.1Clamped to 0–12 in code; 0 means unlimited
Rounding minutesnumber06050 disables rounding
Oversleep creditbooleanApplied up to running balance
Max extra per daynumber060.1For catch‑up plan
Nap allowancenumber040.1For catch‑up plan

I/O formats

Inputs and outputs
Input Accepted Families Output Encoding/Precision Notes
Hours per nightNumbersSummary tableTwo decimalsCopy or download CSV; DOCX export
Daily breakdownTwo decimalsCopy or download CSV; DOCX export
Catch‑up planTwo decimalsCopy or download CSV; DOCX export
JSON payloadStructured fieldsCopy or download JSON
Debt chartRounded valuesCumulative after each night

Networking & storage

  • Processing is browser‑based; copying, downloads, and charting run on the client.
  • One external script is referenced for the charting layer; metrics render even if it is blocked.
  • No user entries are transmitted to a server by the calculator.

Assumptions & limitations

  • Sleep need is treated as constant over the selected horizon.
  • Sleep quality, timing, and fragmentation are not modeled.
  • Only planned naps are included in the catch‑up estimate, not in nightly logs.
  • Older nights beyond the horizon are ignored.
  • Rounding can slightly inflate or deflate totals depending on block size.
  • Heads‑up Large nightly caps can hide severe shortfalls; small caps can understate challenging nights.
  • Oversleep credit never exceeds the current running balance.
  • Catch‑up plan length is bounded to a practical limit of 60 days.

Edge cases & error sources

  • Non‑numeric or negative inputs are sanitized to zero before use.
  • Deficit cap values are clamped to a safe range; entering very large numbers has no extra effect.
  • Rounding minutes over the limit are clamped; zero disables rounding.
  • Extremely long nights are bounded by the nightly input limit.
  • If catch‑up capacity per day is zero, days to clear is reported as zero.
  • Floating‑point rounding may produce small visual differences versus mental math.
  • Chart unavailable when the external chart script cannot load; tables and exports still work.
  • Clipboard or download permissions can fail due to browser policies.
  • Locale settings that change decimal separators may affect input parsing.
  • Rapid edits are debounced; the chart updates after a short delay.

How to Use:

Sleep debt estimation compares your target to recent nights and produces totals, a chart, and an optional catch‑up plan.

  1. Enter your sleep need in hours per night.
  2. Choose a horizon of 7 or 14 nights.
  3. Fill recent nights starting with the most recent at the top.
  4. Optionally set rounding, a nightly cap, and enable oversleep credit.
  5. Set planned max extra per day and nap allowance to see a catch‑up plan.
  6. Review the summary, daily table, plan, chart, or JSON as needed.

Example: Need 8.0 h, horizon 7, rounding off, cap 2.0 h, credit on, extra 1.5 h, naps 0.5 h.

  • Tip: keep rounding consistent to compare weeks cleanly.

FAQ:

Is my data stored?

No. Calculations and exports run on your device, and entries are not sent to a server. The chart script may load from an external source.

If that script is blocked, charts are skipped but tables remain.
How accurate is the balance?

It sums hours below your target after optional rounding and caps, then subtracts applied credit. It does not assess sleep quality or timing.

What units can I enter?

Enter hours with a decimal point. Minute rounding applies first, then deficits and credits are calculated with two‑decimal displays.

Can I use it without a connection?

Metrics and exports work once loaded. The chart depends on an external script and may be unavailable if the connection drops.

What does zero debt mean?

A zero balance means your rounded nights met or exceeded your target after credit rules. It is not a guarantee of ideal rest or alertness.

How do I get a catch‑up plan?

Set max extra per day and optional naps. The plan allocates those hours until the running balance reaches zero, up to a 60‑day limit.

Does it cost anything?

No licensing terms are included here. Availability and terms depend on where this calculator is hosted.

Glossary:

Sleep need (H)
Target hours of sleep per night for comparison.
Horizon (N)
Number of recent nights included in the balance.
Nightly deficit
Portion of need unmet after rounding and capping.
Oversleep credit
Surplus applied to reduce the running balance.
Gross deficit
Sum of nightly shortfalls before credit.
Net sleep debt
Final cumulative balance after all nights.
Catch‑up capacity (r)
Planned extra per day from nights and naps.