Export Spotify playlists to CSV or JSON directly from the terminal, inspired by pavelkomarov/exportify.
This tool can export all saved playlists, including liked songs.
You can also download a binary from the releases page and skip steps 1 and 2. It's recommended to place it in a dedicated folder since it will create .cache, a config file and playlists folders.
- Clone this repository:
git clone https://github.com/donmerendolo/exportify-cli.git- Install the required packages:
cd exportify-cli
uv sync- Set up Client ID, a Redirect URI and a refresh token:
Create a Spotify app in the Spotify Developer Dashboard and copy its Client ID and Redirect URI. The first time you run exportify-cli, it will guide you through the setup:
File "config.cfg" not found or invalid. Let's create it.
Use a Client ID and Redirect URI that belong to the same Spotify app.
Spotify Client ID:
Redirect URI:
Enter the URL you were redirected to:
If you wish to log out, run:
python exportify-cli.py --logoutYou may also revoke access in https://www.spotify.com/us/account/apps/.
Usage: exportify-cli.py (-a | -p NAME|ID|URL|URI [-p ...] | -u ID|URL|URI | -l
| --logout) [OPTIONS]
Export Spotify playlists to CSV or JSON.
Options:
-a, --all Export all playlists
-p, --playlist NAME|ID|URL|URI
Export a Spotify playlist given name, ID,
URL, or URI; repeatable.
-u, --user ID|URL|URI Export all public playlists of a Spotify
user given ID, URL, or URI; repeatable.
-l, --list List available playlists.
--logout Delete cached Spotify auth token and exit.
-c, --config PATH Path to configuration file (default is
./config.cfg next to this script).
-o, --output PATH Directory to save exported files (default is
./playlists).
-f, --format [csv|json] Output file format (defaults to 'csv');
repeatable.
--uris Include album and artist URIs.
--external-ids Include track ISRC and album UPC.
--no-bar Hide progress bar.
--sort-key TEXT Key to sort tracks by (default is
'spotify_default').
--reverse Reverse the sort order.
-h, --help Show this message and exit.
-v, --version Show the version and exit.
- Default values can be changed in
config.cfg. - Playlists to export can be set in
config.cfgvia theplaylistskey (comma-separated), overridden by--playlistwhen given. - Playlist names support partial matching, provided they uniquely identify a single playlist.
- You can also export a playlist that's not saved in your library by using its ID, URL, or URI.
- A single command can export multiple playlists by using the
-poption multiple times. Same applies for the-uoption. - You can export all public playlists of any user by using the
-uoption with their user ID, URL, or URI. It won't save Liked Songs from that user, as it's private. - The default fields are:
Position,Track URI,Track Name,Album Name,Artist Name(s),Release Date,Duration_ms,Popularity,Added By,Added At,Record Label. With flags,Album URI(s),Artist URI(s),Track ISRCandAlbum UPCcan be included too. If you want any other field to be added, feel free to open an issue or PR.
# List all saved playlists
python exportify-cli.py --list
# Export all saved playlists, including liked songs with Artist and Album URIs
exportify-cli.exe --all --uris
# Export playlist whose name is "COCHE" to JSON in reverse order
python exportify-cli.py -p COCHE -f json --reverse
# Export playlist whose ID is "2VqAIceMCzBRhzq6zVmDZw" to current directory, sorted by Added At
exportify-cli.exe -p 2VqAIceMCzBRhzq6zVmDZw --output . --sort-key "Added At"
# Export playlist with its URL to both JSON and CSV
exportify-cli.exe -f json -f csv -p https://open.spotify.com/playlist/2VqAIceMCzBRhzq6zVmDZw?si=16df8ae16c2d492b
# Export playlists "Instrumental" and "COCHE" to CSV without progress bar, sorted by Popularity
python exportify-cli.py -p instr -p COCHE -f csv --no-bar --sort-key "popularity"
# Export all public playlists of user with ID "spotifyuser123" and user with URL "https://open.spotify.com/user/anotheruser456"
python exportify-cli.py -u spotifyuser123 -u https://open.spotify.com/user/anotheruser456
You can use PyInstaller to build a binary with this command:
pyinstaller --onefile .\exportify-cli.py