diff --git a/format.c b/format.c
index 530e2403..17e54996 100644
--- a/format.c
+++ b/format.c
@@ -1797,6 +1797,11 @@ format_defaults_winlink(struct format_tree *ft, struct winlink *wl)
 	format_add(ft, "window_flags", "%s", window_printable_flags(wl));
 	format_add(ft, "window_active", "%d", wl == s->curw);
 
+	format_add(ft, "window_start_flag", "%d",
+	    !!(wl == RB_MIN(winlinks, &s->windows)));
+	format_add(ft, "window_end_flag", "%d",
+	    !!(wl == RB_MAX(winlinks, &s->windows)));
+
 	format_add(ft, "window_bell_flag", "%d",
 	    !!(wl->flags & WINLINK_BELL));
 	format_add(ft, "window_activity_flag", "%d",
diff --git a/tmux.1 b/tmux.1
index 12da91ec..91c60f8e 100644
--- a/tmux.1
+++ b/tmux.1
@@ -3875,6 +3875,7 @@ The following variables are available, where appropriate:
 .It Li "window_activity_flag" Ta "" Ta "1 if window has activity"
 .It Li "window_active" Ta "" Ta "1 if window active"
 .It Li "window_bell_flag" Ta "" Ta "1 if window has bell"
+.It Li "window_end_flag" Ta "" Ta "1 if window has the highest index"
 .It Li "window_flags" Ta "#F" Ta "Window flags"
 .It Li "window_format" Ta "" Ta "1 if format is for a window (not assuming the current)"
 .It Li "window_height" Ta "" Ta "Height of window"
@@ -3887,6 +3888,7 @@ The following variables are available, where appropriate:
 .It Li "window_panes" Ta "" Ta "Number of panes in window"
 .It Li "window_silence_flag" Ta "" Ta "1 if window has silence alert"
 .It Li "window_stack_index" Ta "" Ta "Index in session most recent stack"
+.It Li "window_start_flag" Ta "" Ta "1 if window has the lowest index"
 .It Li "window_visible_layout" Ta "" Ta "Window layout description, respecting zoomed window panes"
 .It Li "window_width" Ta "" Ta "Width of window"
 .It Li "window_zoomed_flag" Ta "" Ta "1 if window is zoomed"