How to Extract Clean Text from SRT or VTT Subtitle Files
Pulling the plain dialogue out of a subtitle file sounds trivial until you hit cue numbers, timestamps, and sentences split mid-line. Here's how to do it properly.
Subtitle files store three things interleaved together: an index number, a timing range, and the actual text. If all you want is the text (for a blog quote, an article, a search index, or feeding into another tool), the timing and numbering are just noise you need to strip out.
The manual approach, and where it breaks
A quick find-and-replace with a regex for timestamp lines (\d{2}:\d{2}:\d{2}[,.]\d{3}\s*-->\s*...) handles the obvious case. Where it falls apart:
- Cue numbers that look like text. A line that’s just
42on its own could be a cue index, or, rarely, part of the actual dialogue (a character reading a number aloud). Naive stripping can’t always tell the difference reliably at scale. - Sentences split across cues. Subtitles are chunked for on-screen readability (roughly one line per few seconds), not for grammar. A single sentence routinely spans two or three consecutive cues. Stripping the timing lines without rejoining the fragments leaves you with choppy, disconnected sentence pieces instead of flowing prose.
- Inline formatting tags.
<i>,<b>, and VTT’s voice/color tags (<v Speaker>,<c.colorname>) need to be stripped too, or they’ll show up as literal angle-bracket text in your output. - Mixed line endings. Files exported from different tools or operating systems sometimes mix
\r\nand\n, which can break regex patterns that assume one or the other.
What good output looks like
Properly extracted text reads like normal prose: full sentences, paragraph breaks where there are natural pauses, no stray numbers or timestamp fragments, no leftover markup. The goal is a document that reads as if someone had simply transcribed the dialogue in the first place, with no trace of the subtitle format it came from.
Doing it without the manual cleanup
Our SRT to TXT converter (and the matching VTT to TXT converter) handles all of this automatically: cue numbers and timestamps removed, tags stripped, sentences that were split across cues rejoined into coherent paragraphs. It runs entirely in your browser, so nothing in the file is sent anywhere.