Turning YouTube caption files into clean text and SRT, and the four traps on the way 🧹 A self-taught developer in Nairobi built an Apify Actor that converts YouTube caption files into clean transcript text and SRT subtitles for AI use cases like channel chatbots, summaries and search. The writeup details four parsing traps in YouTube's srv1 XML caption format, including double-encoded entities, styling tags and line breaks inside caption lines, and offers a decode-until-stable entity decoder capped at three passes plus a regex-based line parser. Quotes encoded twice, tags inside lines, two kinds of English, and subtitles that talk over each other. Hi I'm Tim, a self-taught developer in Nairobi. I build small data tools that run as Apify Actors, serverless jobs that people pay for per result. One of them turns YouTube videos into transcripts. Most people want those for AI tools: a chatbot over a channel, summaries, search. Some want subtitle files. Either way, the job ends with the same small problem: a caption file comes in, and clean text has to come out. This post skips how you get the file and looks at what's inside it, because that's where the surprises are. YouTube serves captions in several formats. The simplest is an XML format called srv1 tools like yt-dlp can save captions in it too . It looks like this: