{
  "id": 17336138,
  "title": "I wrote an SRT-to-WebVTT converter in ~35 lines because players lie about subtitle support",
  "url": "https://urgent.news/2026/10/31/i-wrote-an-srt-to-webvtt-converter-in-35-lines-because-players-lie",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-31T04:18:41.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/hammiwor/i-wrote-an-srt-to-webvtt-converter-in-35-lines-because-players-lie-about-subtitle-support-17ni"
  },
  "original_language": "en",
  "account": "I constructed an SRT-to-WebVTT converter in approximately 35 lines of code for a 0.91 MB Android media player. Most streams provide subtitle files in the SRT format, which is not compatible with the WebVTT format used by the video element. The key differences between SRT and WebVTT lie in timestamps and cue indexing. SRT uses a colon and milliseconds, while WebVTT requires a period and milliseconds. Additionally, SRT files start with a numeric counter line, which WebVTT treats as a cue ID. The converter, named captionVtt(), handles various issues such as BOM, line endings, cue counter, timing format, and text cleaning. It strips the BOM and Windows line endings, splits the file into blocks, removes the cue counter line, converts commas to periods in the timing line, and cleans the text lines by removing tags and entities. Despite the complexity, the converter is surprisingly concise at about 35 lines. However, the parsing process is more robust than accurate due to the inconsistencies in SRT files. Developers are advised to always use WebVTT when embedding subtitles and validate them using a real <track> element in the browser, as devtools may not warn about comma errors.",
  "summary": "i'm building RKMovies , a 0.91 MB Android media client. the streams come with subtitle files, and the internet almost always hands you SRT. the problem: the <video> element only renders WebVTT properly, and SRT is not WebVTT. the differences that actually bite: timestamps. SRT uses 00:00:01,000 . WebVTT demands 00:00:01.000 . one comma and the whole cue silently disappears. cue indexes. SRT…",
  "key_points": [
    "Converted SRT to WebVTT in 35 lines of code",
    "Addressed timestamp and cue indexing differences",
    "Handles BOM, line endings, and text cleaning"
  ],
  "editors_take": "Building lightweight converters addresses the technical friction between standard subtitle formats and web-based video players, highlighting why developers must prioritize native WebVTT to ensure reliable caption rendering.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}