A Go utility to clean Spotify streaming history JSON files by removing IP address information and combining multiple files into a single cleaned dataset.
- 🧹 Remove IP addresses from Spotify streaming data for privacy
- 📁 Process multiple files at once from a list
- 🔄 Combine all data into a single output file
- ⚡ Fast processing with proper error handling
- 📊 Progress tracking with detailed output
- Make sure you have Go installed (version 1.16+)
- Clone or download this repository
- Build the program:
go build -o spotify-cleaner main.go
-
Create a text file with your JSON filenames (one per line):
echo "Streaming_History_Audio_2024_1.json" > filelist.txt echo "Streaming_History_Audio_2024_2.json" >> filelist.txt echo "Streaming_History_Audio_2024_3.json" >> filelist.txt
-
Run the cleaner:
./spotify-cleaner < filelist.txt
Using echo:
echo -e "file1.json\nfile2.json\nfile3.json" | ./spotify-cleanerUsing here document:
./spotify-cleaner << EOF
Streaming_History_Audio_2024_1.json
Streaming_History_Audio_2024_2.json
Streaming_History_Audio_2024_3.json
EOFDirect compilation and run:
echo -e "file1.json\nfile2.json" | go run main.goThe program expects:
- Input: Text file with JSON filenames (one per line) via stdin
- JSON Files: Spotify streaming history files in JSON array format
Example input file (filelist.txt):
Streaming_History_Audio_2020-2021_0.json
Streaming_History_Audio_2021-2022_1.json
Streaming_History_Audio_2022-2023_2.json
- File:
spotify_cleaned_[timestamp].json - Format: Single JSON array containing all cleaned records
- Removed:
ip_addrfield from all records - Preserved: All other fields (track name, artist, timestamp, etc.)
Input JSON structure:
[
{
"ts": "2024-01-01T12:00:00Z",
"username": "user123",
"platform": "Android OS",
"ms_played": 240000,
"conn_country": "US",
"ip_addr": "192.168.1.1",
"master_metadata_track_name": "Song Title",
"master_metadata_album_artist_name": "Artist Name"
}
]Output JSON structure:
[
{
"ts": "2024-01-01T12:00:00Z",
"username": "user123",
"platform": "Android OS",
"ms_played": 240000,
"conn_country": "US",
"master_metadata_track_name": "Song Title",
"master_metadata_album_artist_name": "Artist Name"
}
]The program handles:
- ✅ Missing files (skips and continues)
- ✅ Invalid JSON format (skips and continues)
- ✅ Empty input (exits with error)
- ✅ File permission issues
- ✅ Malformed filenames
This tool is designed to help protect your privacy by removing IP address information from Spotify data exports while preserving all music listening history and metadata.
- Go 1.16 or higher
- Read access to JSON files
- Write access to current directory
"No filenames provided"
- Make sure your input file contains filenames
- Check that you're using
<or|to pipe input
"Error reading file"
- Verify file paths are correct
- Check file permissions
- Ensure files exist in the current directory
"Error parsing JSON"
- Verify files are valid JSON format
- Check for corrupted downloads from Spotify