YouTube Watch History Extractor is a Python script that parses and extracts structured data from a YouTube watch-history.html file. It converts your YouTube watch history into CSV and JSON formats, making it easier to analyze trends, track favorite creators, and build datasets for further research.

- ✅ Extracts video titles, URLs, channel names, timestamps from YouTube history.
- ✅ Outputs structured CSV and JSON files for easy data manipulation.
- ✅ Efficient HTML parsing with BeautifulSoup.
- ✅ Handles large history files smoothly (40MB HTML file ≈ 40 minutes runtime of python script).
- ✅ Useful for personal analytics, recommendations, and archiving.
CSV (watched_history.csv)
| video_title | video_url | channel_name | channel_url | date | time |
|---|---|---|---|---|---|
| Sample Video 1 | abc123xyz | Tech Guru | channel456 | 2024-01-20 | 15:34:12 |
JSON (watched_history.json)
[
{
"video_title": "Sample Video 1",
"video_url": "abc123xyz",
"channel_name": "Tech Guru",
"channel_url": "channel456",
"date": "2024-01-20",
"time": "15:34:12"
}
]Follow these steps to download your watch-history.html file from Google:
- Visit Google Takeout.
- Sign in with your Google account if prompted.
- Click "Deselect all" to remove all other Google data.
- Scroll down and check "YouTube and YouTube Music".

- Click "All YouTube data included", uncheck everything except "History", then click OK.

- Scroll down and click "Next step".
- Under "Delivery method," choose "Download link via email" (or another preferred option).
- Select "Export once" and ".ZIP" format (recommended).

- Click "Create Export".
- Wait for Google to process your request (it may take minutes to hours).
- Once done, download the ZIP file from the email link.
- Extract the ZIP file to access the folder named "Takeout".
- Inside the extracted folder, navigate to:
Takeout > YouTube and YouTube Music > history - Look for a file named
watch-history.html. - Copy this file to the same directory where you'll run this script.
✅ Now you're ready to use the YouTube Watch History Extractor! 🚀
-
Clone the repository
git clone https://github.com/atishramkhe/YouTube-Watch-History-Extractor-Convert-HTML-to-CSV-JSON cd YouTube-Watch-History-Extractor-Convert-HTML-to-CSV-JSON -
Install dependencies Ensure you have Python 3.8+ installed, then run:
pip install -r requirements.txt
-
Place your YouTube history file Download your
watch-history.htmlfrom Google Takeout and move it to the script directory.
Make sure that the watch-history.html file is in the same directory as the Python script. Then, run the script to extract and save history data:
python extract_watch_history.pyThis will generate two output files in the same directory:
watched_history.csvwatched_history.json
- Data Analysis: Track watch patterns and preferences.
- Machine Learning: Train recommendation models based on user history.
- Personal Archiving: Keep records of watched content.
- Integration: Use extracted data for custom dashboards or automation.
Contributions are welcome! Feel free to:
- Report issues 🐞
- Suggest improvements 🚀
- Submit pull requests 📌
This project is licensed under the MIT License.
Created by Atish K. Ramkhelawon
- GitHub: atishramkhe
- LinkedIn: Atish K. Ramkhelawon