NodeJS ID3 tag libraries. Which is the best?

I have been working on my own music player recently written completely in NodeJS, and so today I thought I would do some comparisons between a couple of libraries. I have written a benchmark repo that compares the speed of them that can be found . So straight up here are the raw speed results for reading ID3 tags from a sample file:

$ node bench.js 
taglib x 773 ops/sec ±0.42% (61 runs sampled) 
musicmetadata x 443 ops/sec ±2.55% (79 runs sampled) 
id3js x 464 ops/sec ±8.78% (82 runs sampled) 

And for those that prefer charts:

From this you can see that taglib is the clear winner when it comes to read speed. But don't jump to using that straight away, there are some minor down-sides, and I would like to compare them.

Taglib

Taglib reads all the basic data needed, title, album, artist, genre, etc. However it is missing one valuable attribute that could be time-intensive to read, the images. I suspect this is one of the reasons it is faster than both musicmetadata and id3js which both read images. Taglib does however have write support. So if all you application needs to do is read and write textual metadata with no use for images, then due to it's speed I would go with taglib.
One other nice bonus about taglib is that it is able to read the duration for all songs I have tested. How it does this I don't know, but it could be due to the fact I think it works with some raw C code for it's backend.

MusicMetadata

This library is a fork of the original musicmetadata library by aadsm. It functionally works very well, giving all data needed + images in a normalised fashion (not splitting id3v1 and id3v2 attributes). It is just over half the speed of taglib but does not support writing data. So if your application needs images but does not need write support, musicmetadata is a safe bet.

id3js

This library has roughly all the same features as musicmetadata except that it does not normalise the attributes, it keeps them split as id3v1 and id3v2 attributes, but does normalise some of them (title, album, artist and year). It also has the images available as part of the id3v2 attributes. This library also does not have write support.

Conclusion

To conclude, if you don't need images, then use taglib, it is a great all-rounder and is super fast. The fact that it includes song durations is great. However if you need cover image fetching you will need to also use either musicmetadata or id3js. Note here that there is no library for writing images to the metadata.

Raw Results

For anyone intested in the raw output of the different programs here is the output of my test.js

$ node test.js

here

Benjamin Kaiser

Benjamin Kaiser

Software Engineer working on the SharePoint team at Microsoft. I'm passionate about open source, slurpess, and Jesus.
Gold Coast, Australia

Post Comments