YouTube Tools

Export YouTube Playlist to SQLite

Paste a playlist link to download a SQLite database of its videos and answer questions with SQL, like the most-viewed videos or total watch time.

How to export a YouTube playlist to SQLite

  1. 01

    Paste the playlist link

    Copy the link of any public or unlisted playlist and press Export. Every video is read, however long the playlist is.

  2. 02

    SQLite is already ticked

    Pick the columns of the videos table: title, video ID, durations, views, likes, comments, description, tags and more.

  3. 03

    Download

    Press Download to get a .sqlite file and open it in DB Browser for SQLite, the sqlite3 shell or your own code.

What's in the database

The file has two tables. playlist holds one row with the id, title, channel, url, video_count and exported_at. videos holds one row per video in playlist order, with a column for each field you pick, named in snake_case like video_id and duration_text, and typed INTEGER, REAL or TEXT.

Lists such as tags and description links are stored as JSON arrays, so SQLite's json_each() can split them, and watched is 1 or 0. Try SELECT title, views FROM videos ORDER BY views DESC LIMIT 10.

Frequently asked questions

How do I open the .sqlite file?

Use DB Browser for SQLite or TablePlus, run sqlite3 playlist.sqlite in a terminal, or open it from Python with sqlite3.connect. Datasette can publish it as a website.

How do I count videos per tag?

Tick Tags, then run SELECT tag.value, count(*) FROM videos, json_each(videos.tags) AS tag GROUP BY tag.value ORDER BY 2 DESC.

How do I get the total length of the playlist?

Tick Seconds and run SELECT sum(seconds) / 3600.0 AS hours FROM videos.

Is there a limit on playlist length?

No. Playlists with thousands of videos are read in full, page by page, and you can export only a range with the From and To video numbers.

Export a YouTube playlist to other formats

More YouTube tools

See all tools