Move your Spotify playlists and Liked Songs to YouTube Music for free, with no track limit and matching you can actually trust.
Most transfer services cap free use at a few hundred songs, and they quietly add the wrong song when they can't find the right one (karaoke versions, covers, live recordings). This script:
- Handles any library size. It was built on a 117-playlist, 10,000-entry library.
- Matches carefully. Every candidate is scored on title, artist, and track length. Live, remix, karaoke, sped-up, and "originally performed by…" versions are penalized unless your original is that version too.
- Shows its work before changing anything. Matching produces a spreadsheet you can review and fix before a single playlist is created.
- Handles non-English music. Japanese, Korean, and Chinese titles match, including YouTube's bilingual titles like
짧은 치마 (Miniskirt)orプラスティック・ラブ - Plastic Love. - Is resumable and safe. Every step saves progress, Ctrl+C is fine, reruns never create duplicates, and nothing is ever deleted on either service. Spotify access is read-only.
On a real ~5,100-unique-song library, 94% of playlist entries matched automatically. A manual audit of those matches found 99.8% were the exact right song by the right artist.
1. export Spotify ──► data/spotify_library.json (read-only)
2. match YouTube Music search ──► data/matches.csv (read-only, review here)
3. push data/matches.csv ──► private YouTube Music playlists
- Python 3.10+
- A Spotify account (free or Premium)
- A YouTube Music account (free works; Premium isn't required)
git clone https://github.com/jmpanackal/SpotifyToYoutubeMusic.git
cd SpotifyToYoutubeMusic
pip install -r requirements.txt
Option A: Spotify API (takes about 5 minutes)
-
Go to the Spotify Developer Dashboard and click Create app.
- Name and description: anything
- Redirect URI: exactly
http://127.0.0.1:8888/callback(then click Add) - APIs used: check Web API
-
Open the app, then Settings. Copy the Client ID, click View client secret, and copy that too (use the copy button, since hand-selecting the text often grabs extra characters).
-
Set them in your terminal and run the export:
Windows (PowerShell)
$env:SPOTIPY_CLIENT_ID="your-client-id" $env:SPOTIPY_CLIENT_SECRET="your-client-secret" python migrate.py export
macOS / Linux
export SPOTIPY_CLIENT_ID=your-client-id SPOTIPY_CLIENT_SECRET=your-client-secret python migrate.py export
-
A browser tab asks you to approve read-only access. Approve it.
By default this exports Liked Songs plus every playlist you own or collaborate on. Playlists you only follow (Spotify's editorial playlists, other people's playlists) are skipped and listed so you can see them. Add --include-followed to include them.
Option B: Spotify data download (no developer app)
In Spotify, go to Account → Privacy settings → Download your data and request the Account data package. It usually arrives within a few days. Unzip it, then:
python migrate.py import-export path/to/my_spotify_data
This export has no track lengths, so matching is a little less precise than Option A.
ytmusicapi logs in by reusing your browser's YouTube Music session:
- In Chrome or Edge, open music.youtube.com, signed in to the account you want the playlists on.
- Press F12, open the Network tab, and type
browsein the filter box. Click Library in YouTube Music. - Click a
browse?…request whose Request Method is POST. Under Request Headers, select the whole section and copy it. Don't worry about where it starts; it just needs to includecookieandx-goog-authuser. - Run
ytmusicapi browser, paste, then:- Windows: Enter, Ctrl+Z, Enter
- macOS / Linux: Enter, Ctrl+D
This creates browser.json. It is your logged-in Google session: never share it or commit it (it's in .gitignore).
python migrate.py match
This searches YouTube Music for each unique song (duplicates across playlists are searched once) at roughly 30 to 45 songs per minute. That's about 2 hours for 5,000 unique songs. It's throttled on purpose so Google doesn't rate-limit you. Leave it running; if it stops, rerun the same command and it picks up where it left off. Occasional JSONDecodeError ... retry lines are normal: YouTube sometimes sends an empty reply, and the script retries.
Then do a second pass for anything not confidently matched, this time also searching regular YouTube videos. That catches underground tracks, fan edits, and SoundCloud-era rap that only exist as uploads:
python migrate.py match --retry-missing --allow-videos
Rows are sorted worst-first:
| status | meaning | added by push? |
|---|---|---|
ok |
right song and right artist (score ≥ 0.80) | yes |
review |
something's off, usually a cover or a different song by the same artist | no |
missing |
nothing good found | no |
To fix a row, paste a YouTube or YouTube Music link (or the 11-character video ID) into override_video_id. To leave a song out, put x in skip. Rerunning match keeps your edits.
python migrate.py push --dry-run # show what would be created, write nothing
python migrate.py push --only "Some Playlist" # test with one playlist first
python migrate.py push # everything
- Playlists are created private, keep your Spotify track order, and drop duplicates.
- YouTube caps playlists at 5,000 tracks, so larger ones are split into
Name (1/2),Name (2/2). - Pushing is quick, roughly 5 to 10 minutes for 10,000 tracks.
- Rerunning only adds what's missing. To redo a playlist, delete it in YouTube Music and remove its entry from
data/push_state.json.
| command | flag | what it does |
|---|---|---|
export |
--include-followed |
also export playlists you follow but don't own |
export, import-export |
--no-liked |
skip Liked Songs |
match |
--allow-videos |
fall back to regular YouTube videos when no good song result exists |
match |
--retry-missing |
re-search everything not marked ok |
match |
--delay 0.6 |
seconds between searches |
push |
--dry-run |
print the plan, change nothing |
push |
--only NAME ... |
push only these playlists |
push |
--prefix "SP - " |
prefix every playlist name |
push |
--privacy PRIVATE|UNLISTED|PUBLIC |
playlist visibility (default PRIVATE) |
push |
--min-score 0.8 |
match confidence required (lower it to include review rows; not recommended) |
push |
--liked-as-thumbs |
thumbs-up your Liked Songs in YouTube Music instead of making a playlist; trains recommendations, but it's one request per song |
- Spotify: remove the app at spotify.com/account/apps, or delete it in the Developer Dashboard.
- YouTube: sign out of YouTube Music in the browser you copied headers from. That ends the session
browser.jsonwas using. - Delete
browser.jsonanddata/.spotify_token.
| problem | fix |
|---|---|
invalid_client, Invalid client secret |
The secret was mis-pasted. In PowerShell, $env:SPOTIPY_CLIENT_SECRET.Length should print 32. Re-copy it with the copy button, or click Rotate client secret and use the new one. |
INVALID_CLIENT: Invalid redirect URI |
The redirect URI in the dashboard must be exactly http://127.0.0.1:8888/callback. |
403 errors during export |
Spotify keeps tightening developer-app rules. Use Option B (data download) instead. |
| Some playlists export empty | Open one in Spotify. If it has songs, Spotify's API is hiding them; Option B usually includes them. |
The following entries are missing in your headers |
Wrong request copied. Pick a POST browse request while signed in. |
match or push suddenly fails with auth errors |
Your YouTube session expired, or you signed out. Redo Step 2; progress is kept. |
--only can't find a playlist with emoji in its name |
Some terminals mangle emoji in arguments. Test with a plain-named playlist. |
ytmusicapiis an unofficial library, so YouTube can change things and break it without notice.- Songs that aren't on YouTube at all can't be matched. Local files only match if the song happens to exist there.
- A small share of matches come from regular YouTube uploads (when
--allow-videosis used) rather than official YouTube Music tracks.
python -m unittest discover -s tests -v
The tests run offline. They cover the matching rules (using real-world misfires as cases) and a full export → match → push run against a fake YouTube Music.
MIT. Not affiliated with Spotify or Google.