Small utility to extract timestamps and their associated transcript text from a YouTube transcript HTML dump or directly from YouTube URLs.
How it works
- For HTML files: The script strips HTML tags and uses a simple regex to find timestamps (e.g.
0:00,1:06). - For YouTube URLs: The script fetches the transcript using the YouTube API and converts it to the same format.
- For each timestamp it captures the following text up to the next timestamp and outputs pairs in the selected format.
- Python 3 (tested on 3.8+)
youtube-transcript-api(optional, only required for YouTube URL inputs):pip install youtube-transcript-apistreamlit(optional, only required for the Web GUI):pip install streamlit
Available online : https://samgvann-youtubetanscripttotext.streamlit.app

Or locally, to run the interactive web interface simply run (after installing requirements):
streamlit run app.pyThis will open a modern web app in your browser where you can paste URLs or upload HTML files, preview the output, and download the results.
Interactive (default): the script will ask a few numbered questions when run without --format or -o:
-
Whether to include timestamps in the output
1)With timestamps (default)2)Without timestamps
-
Output format (choose the option number)
1)tsv(default)2)txt3)md
-
Output filename (enter a name without extension). Press Enter to use the default
output. For URLs, default base istranscript.
Example (interactive with file):
python extractor.py example.txtExample (interactive with URL):
python extractor.py https://www.youtube.com/watch?v=dQw4w9WgXcQNon-interactive (flags): you can skip prompts by providing --format and/or -o:
python extractor.py example.txt -o output.tsv --format tsvpython extractor.py https://www.youtube.com/watch?v=dQw4w9WgXcQ -o transcript.tsv --format tsvWhen running non-interactively the provided -o/--output should include the extension (e.g. output.tsv).
Supported formats:
tsv— tab-separated file:TIME<TAB>TEXT(orTEXTonly if you chose to omit timestamps)txt— plain text lines:TIME - TEXT(orTEXTonly when timestamps are omitted)md— Markdown table. If timestamps are included the table isTime | Text; when timestamps are omitted the table contains a singleTextcolumn.
extractor.py— extraction scriptexample.txt— example HTML transcript (input)requirements.txt— Python dependencies
- For YouTube URLs, the script automatically tries multiple languages (English, Spanish, French, German, Italian, Portuguese, Russian, Japanese, Korean, Chinese) to find an available transcript.
- If no transcript is available for the video, the script will output an error and produce an empty file.
- Interactive defaults: choosing Enter for the filename uses
outputas the base name; the selected format determines the file extension. - The script is intentionally simple and dependency-free. It works well for the HTML structure produced by YouTube's transcript/timeline markup. If your transcripts use a different markup, the parser can be adapted.
- Inspect page
- In the "Elements" pane just search for the HTML tag corresponding to the transcript :
- Copy the HTML tag
-
Paste in "example.txt"
-
run python script from your terminal :
python extractor.py example.txt
