A WebVTT file is UTF-8 text, defined by the W3C’s WebVTT specification. It is a header
followed by blocks, with blank lines between them. Its media type is
text/vtt and its extension .vtt. Fragment identifiers have no
meaning with text/vtt resources (the media type registration in the W3C
specification).
Header
| Part | Bytes or text | Notes |
|---|---|---|
| Byte order mark | EF BB BF | Optional. |
| Signature | WEBVTT (57 45 42 56 54 54) | Required. Must be followed by a space, a tab, a line ending or the end of the file, so WEBVTTX is not a WebVTT file. |
| Header text | a space or tab, then any text | Optional, on the same line, such as WEBVTT - Episode 1. Players ignore it. |
| Blank line | two or more line endings | Ends the header. |
A line ending is CR LF, LF or CR. The text is always UTF-8; there is no way to declare another encoding.
Older header grammar (W3C Working Draft, 8 December 2015)
The W3C Working Draft of 8 December 2015 (sections 4.1 and 4.3) defined the part after the first line differently, and files made before the 2016 revision may still follow it. Today’s specification has no metadata headers: a parser skips whatever follows the first line up to the first blank line (see below), so those files still read, but their header lines mean nothing to a current player.
- Metadata headers. After the first line, the body had zero or more
WebVTT metadata headers. Each was a name, a colon, a value and a line terminator. The
name and the value were each one or more characters other than LF and CR, and the
whole string must not contain
-->. One or more line terminators then ended the header block, before the style blocks and cue blocks. - Regions in the header. A region was defined by a region
metadata header: a metadata header whose name was the string
Regionand whose value was a region setting list, such asRegion:id=speaker width=40% lines=3. There was noREGIONblock. The setting list held zero or more settings in any order, separated by spaces or tabs, each at most once:id=(one or more characters other than space and tab, no-->, unique in the file),width=(a percentage),lines=(one or more digits),regionanchor=(two percentages separated by a comma; default 0%,100%),viewportanchor=(two percentages separated by a comma; default 0%,100%) andscroll=up. Today’sREGIONblock writes the same settings with a colon instead of=, one per line; see Regions. - HLS. The HLS
X-TIMESTAMP-MAPline is such a metadata header, which is why HLS still depends on it.
How a parser reads the input
From the W3C parsing algorithm (WebVTT section 6.1 and 2.2):
- The bytes are decoded as UTF-8. Then every U+0000 NULL is replaced by U+FFFD REPLACEMENT CHARACTER, each CR LF pair by one LF, and each remaining CR by an LF. After this, only LF is a line ending.
- Signature. A string shorter than six characters, or exactly six
that is not
WEBVTT, or longer with a different first six characters or a seventh that is not a space, a tab or an LF, is not a WebVTT file and parsing stops. A file that is exactlyWEBVTT, or has nothing after the first line, is valid but holds no cues. - Header block. The rest of the first line is skipped. If the next line
is not blank, the non-blank lines that follow, up to the first blank line, form a
header block that the parser skips, so extra lines such as
X-TIMESTAMP-MAP=…and the older metadata headers are tolerated. A header line that contains-->ends the header block there instead and is read as the start of a cue block. - No normalisation. A parser must not apply Unicode normalisation. A cue identifier or voice name written as a decomposed sequence (A and U+030A) or with a compatibility character (U+212B) does not match a CSS selector written with the precomposed character (U+00C5), because matching is by exact code points.
- Blocks. Each block ends at a blank line. A block whose first line is
STYLEorREGION(with only white space after it) is taken as a style sheet or a region only while no cue has been seen. A line containing-->is the timing line when it is the first line of the block, or the second line after an identifier line; anywhere else it ends the current block and starts a new block at that line.
Chapter titles. To show a chapter list, a player parses the cue text
with the cue text rules and takes
the concatenation of the text nodes in document order, leaving out the text of
rt ruby text (WebVTT section 6.6).
Blocks
Blocks are separated by one or more blank lines, and no block may contain a blank line. They come in this order:
REGION,STYLEandNOTEblocks, in any order;- then cue and
NOTEblocks.
Once the first cue has appeared, a STYLE or REGION block is
no longer recognised. A block that is none of these is ignored.
| Block | First line | Then | Meaning |
|---|---|---|---|
| Cue | an optional identifier, or the timing line | the timing line, then the text | Text shown for a time. See Cues and settings. |
| Comment | NOTE, then a space, a tab or a line ending, and any text | more comment lines | Ignored by players. |
| Style | STYLE, optionally followed by spaces or tabs | a CSS style sheet | Styles for the cues. See Styling with CSS. |
| Region | REGION, optionally followed by spaces or tabs | region settings | A named area of the screen. See Regions. |
The three characters --> may not appear anywhere in a comment, style
sheet, identifier or cue text, because a parser takes any line containing them as a
timing line.
Kinds of file
Every cue in one file holds the same kind of data. The file does not say which; the
web page does, with the kind of its <track>
element.
| Kind | Cue text | Rule |
|---|---|---|
| Subtitles or captions | Text with tags and character references | Cues may overlap freely. |
| Chapters | A plain title: text and character references, no tags | Cues must nest: any two either do not overlap, or one lies wholly inside the other. |
| Metadata | Any text with no blank line, such as JSON, for scripts to read | None. |
Timestamp map in HLS
HLS (M3U8) cuts WebVTT into segments to run beside MPEG-2 transport stream video, and RFC 8216 adds one header line so that cue times can be matched to the video’s clock:
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
00:00:01.000 --> 00:00:03.500
Where are we going?
MPEGTS is a 90 kHz presentation timestamp, here 10 seconds,
that corresponds to the cue time LOCAL. So this cue shows at 11 s on the
video’s clock. The line goes directly after WEBVTT, before the blank
line that ends the header.RFC 8216 section 3.5 sets these rules for a WebVTT segment, the part of a WebVTT file that one playlist entry points to. Apple’s Internet-Draft draft-pantos-hls-rfc8216bis (R. Pantos), which revises that RFC, repeats them in its section 3.1.4 with the changes noted in each item (version -22, May 2026; the text is the same in -20 and -21):
- The segment’s media initialization section is the WebVTT header.
- A segment must contain every cue that is to be displayed during the period given by
its
EXTINFduration. Each cue keeps its full start and end times, even when part of the cue lies outside the segment’s period, so a cue that spans two segments is written in both with the same times. The draft adds one exception: where the cue duration cannot be known when the segment is made (its example is live streaming) and the cue’s interval is split over several segments, the cue time range in each segment may be limited to the WebVTT time range the segment covers. - A segment may contain no cues; that means no subtitles are displayed in that period.
- A segment must either start with a WebVTT header or have an
EXT-X-MAPtag applied to it (the map then supplies the header). X-TIMESTAMP-MAP=LOCAL:<cue time>,MPEGTS:<MPEG-2 time>maps cue times to the timestamps of the other renditions of the variant stream. RFC 8216 says it should be added to each WebVTT header and calls the other timestamps MPEG-2 (PES) timestamps. The draft says it should be among the set of non-blank lines immediately after theWEBVTTline, and that when it is present this set of non-blank lines must be followed by two or more line terminators, then the rest of the body; the draft calls the other timestamps media timestamps. TheLOCALcue time may lie outside the time covered by the segment.- Draft only: the
MPEGTSvalue must use a 90 kHz timescale, even when the non-WebVTT media segments use a different timescale. - A WebVTT segment that has no
X-TIMESTAMP-MAPline: a client must assume that the cue time 0 maps to the media timestamp 0 (RFC 8216: the MPEG-2 timestamp 0). - PES timestamps are 33-bit and wrap, while cue times do not; when synchronising,
clients should account for a wrapped timestamp against an unwrapped cue time.
The draft adds: when the PES timestamp wraps, the WebVTT segment
should have an
X-TIMESTAMP-MAPheader that maps the current WebVTT time to the new, low-valued PES timestamp.
The draft also records, in its reference to the 2015 Working Draft, that HLS added this metadata header in 2012 and that when the WebVTT specification dropped metadata headers in 2016 there was already substantial content using it. See Header for the old grammar.
WebVTT in MP4
WebVTT can also be carried as a track inside an MP4, fragmented MP4 or CMAF file. That
is a separate format with its own boxes, not part of a .vtt file, and it
is described on WebVTT in MP4.
Worked example
WEBVTT - Episode 1
REGION
id:speaker
width:40%
lines:3
regionanchor:0%,100%
viewportanchor:10%,90%
scroll:up
STYLE
::cue(.loud) { font-weight: bold; }
NOTE Dialogue starts here
intro-1
00:01.000 --> 00:03.500 region:speaker
<v Anna>Where are we going?
00:04.000 --> 00:06.250 line:0 align:start
<v.loud Ben>Somewhere we have never been!