Articles
Published · November 18, 2026

Subtitles as Plain Text: Writing SRT and WebVTT Files by Hand

Write an SRT or WebVTT subtitle file in a text editor: cue syntax, the comma versus period in timestamps, escaping, encoding, and the track element.

Also in: Español中文हिन्दी

A subtitle file is a plain text file with timestamps. SRT and WebVTT both fit in any text editor, and the biggest difference between them is one character: SRT writes 00:00:01,000 with a comma, WebVTT writes 00:00:01.000 with a period. If you keep notes in plain text, you already have the tools. Below you'll find the cue syntax for each format, how to convert between them, and the rules that trip people up. (ChordPro is another plain text format built on the same idea: structure you can read and edit by hand.)

Quick answer

Each subtitle is a block of lines, and blocks are separated by a blank line. In SRT the block is a counter, a timing line, and the text. In WebVTT the file starts with WEBVTT, and the counter becomes an optional identifier. Save it as UTF-8 with the .srt or .vtt extension.

Anatomy of an SRT cue

According to the SubRip article on Wikipedia, each SRT entry has four parts: a numeric counter, a timing line, the subtitle text on one or more lines, and a blank line that ends the entry. Numbering runs sequentially from 1.

1
00:02:16,612 --> 00:02:19,376
Senator, we're making
our final approach into Coruscant.

2
00:02:19,401 --> 00:02:21,500
Understood. Stand by.

The timing line is hh:mm:ss,mmm --> hh:mm:ss,mmm. Hours, minutes, and seconds are two zero-padded digits, milliseconds are three, and the decimal separator is a comma. Wikipedia notes that basic formatting such as <b>, <i>, <u>, and <font color="..."> is unofficial: some players render those tags, others show them as text.

Anatomy of a WebVTT cue

MDN's WebVTT reference describes the structure. The file starts with a header line, WEBVTT, followed by a blank line. The header is the only required part, so the shortest valid WebVTT file is that one word. Optional STYLE, REGION, and NOTE blocks come next, then the cues.

WEBVTT

NOTE Interview, take 2. Check the name spelling in cue 2.

intro
00:01.000 --> 00:04.000
Never drink liquid nitrogen.

00:05.000 --> 00:09.000 line:0 align:start
Because:
- It will perforate your stomach.
- You could die.

A few details matter:

  • The cue identifier (intro above) is optional, goes on its own line before the timing line, and cannot contain -->.
  • Timestamps are mm:ss.ttt or hh:mm:ss.ttt, so the hours can be left out. The separator before milliseconds is a period.
  • The end time must be later than the start time. Cues may overlap.
  • Cue settings such as line, position, size, and align go on the timing line after the end time.
  • A NOTE block is a comment. It can span lines but cannot contain a blank line.

SRT vs WebVTT: the comma and the period

| | SRT | WebVTT | |---|---|---| | First line | The first counter, 1 | WEBVTT | | Cue number | Required, sequential | Optional identifier | | Milliseconds separator | Comma | Period | | Hours | Always written | Optional | | Comments | None | NOTE blocks | | Styling | Unofficial HTML-like tags | STYLE blocks, cue settings, tags | | Encoding | No official encoding | UTF-8 |

To convert SRT to WebVTT by hand:

  1. Add WEBVTT as the first line, then a blank line.
  2. Replace the comma with a period in every timing line. Do this only on lines containing -->, because a global find and replace would also change commas in the dialogue.
  3. Delete the counters if you like, or keep them as identifiers.
  4. Save the file with a .vtt extension.

Renaming the file isn't enough. Without the header, a WebVTT parser rejects the file. With commas in the timestamps, the cue times are invalid.

Text inside a cue

In WebVTT, a cue's text can span several lines but cannot contain a blank line, because that would end the cue. It also cannot contain -->, and an & or < must be escaped as &amp; and &lt;. MDN recommends &gt; over a raw > as well.

WebVTT supports tags in cue text: <i>, <b>, <u>, a voice tag such as <v Bob>, and a language tag such as <lang en-GB>. They are not allowed in chapters tracks.

00:12.000 --> 00:15.000
<v Maria>Tom &amp; Jerry is on at <i>eight</i>.

Encoding and line endings

WebVTT files must be UTF-8. SRT has no official character encoding, which is why older files may be Windows-1252, and a parser has to guess. Wikipedia notes that YouTube accepts only UTF-8 and that FFmpeg defaults to UTF-8 for subtitles. Save as UTF-8 and most surprises disappear. If accented letters turn into odd symbols, see how to fix encoding problems in a text file, and check your CRLF vs LF line endings if a tool complains about blank lines.

Using a .vtt file in a web page

The HTML <track> element attaches a WebVTT file to a video. MDN's track reference says tracks are formatted in WebVTT, so convert SRT first.

<video controls src="friday.mp4">
  <track default kind="captions" srclang="en"
         label="English" src="friday.vtt" />
</video>

src is required and must be same-origin unless the video element has a crossorigin attribute. srclang is required when kind is subtitles, and only one track should carry default. Use kind="captions" when the track also describes sound effects, not just dialogue.

Doing this with Carets

Subtitle files are the kind of file a plain text editor should handle well. Carets is a native notes and code editor for iPhone, iPad, and Mac, so you can open an .srt or .vtt file, fix a timestamp or a typo in a cue, and save it as plain text, with no export step and no proprietary format. Files, projects, and tags keep the subtitle files for each video together, and the same editor holds your notes and scripts. Your subtitles stay plain text, portable to any player.

Get Carets for iPhone, iPad, and Mac on the App Store.

Frequently Asked Questions

Can I just rename a .srt file to .vtt?

No. A WebVTT file must start with a WEBVTT header line, and its timestamps use a period before the milliseconds, where SRT uses a comma. Add the header, change the commas in the timing lines to periods, and then save as .vtt.

Do WebVTT files need cue numbers?

No. Cue identifiers are optional in WebVTT. If you use one, it goes on its own line before the timing line and cannot contain -->. SRT numbers every entry sequentially from 1.

What encoding should a subtitle file use?

UTF-8. WebVTT requires it, SRT has no official encoding but YouTube accepts only UTF-8, and FFmpeg defaults to UTF-8 for subtitles.

Can the hours be left out of a timestamp?

In WebVTT, yes: 01:05.000 is valid. In SRT the full hh:mm:ss,mmm form is used.