Is the format/schema of the Apple Music “Library.musicdb” used in macOS Catalina documented anywhere?

While Apple Music does not automatically generate an library XML file, this can be done manually in the app itself.

I realize this question is about the format of the actual Music Library.musiclibrary database — which would be cool to know about — you can manually export an XML file which — I will assume — is in the same exact format as the old iTunes XML file by following these steps.

First, open up the Music app, go to the “File” menu and choose the “Library” option.

Music app file menu.

Then, in that list there are two options: “Export Library” and “Export Playlist.” I’m choosing “Export Playlist” for this example.

The “Library” sub menu.

After doing that you will be presented with a fairly standard Apple file save/load interface to save the “Library.xml” file and there you go!

The file save interface.

While definitely not as convenient as the old way it was constantly generated in iTunes, I believe this should work well for apps that require the XML file.

Slightly snarky note/criticism from a programer: Why isn’t there a JSON formatting option for export? Let users choose XML or JSON based on needs since — honestly — nobody really likes dealing with XML in 2019. But I digress…


There's a framework called iTunesLibrary that can read Music.app's database - just tested this on macOS Catalina - but it's an Objective-C one.

You may be able to use it via PyObjC, but it will only work if the application is code signed (see the warning there in yellow, at the bottom of the page).

You'd write something like this in Objective-C to access the library:

objective-c
#import <iTunesLibrary/ITLibrary.h>

NSError *error = nil;
ITLibrary *library = [ITLibrary libraryWithAPIVersion:@"1.1" error:&error];
if (library)
{
        NSArray *playlists = library.allPlaylists; //  <- NSArray of ITLibPlaylist
        NSArray *tracks = library.allMediaItems; //  <- NSArray of ITLibMediaItem
}

API version 1.1 seems to be for Music.app, whilst 1.0 should be for iTunes.