Music21j: An Interactive Framework for Musical Analysis

Copyright ©2013-19, Michael Scott Cuthbert and cuthbertLab, some rights reserved.

Music21j is a Javascript reinterpretation of the Music21 Python package,
a toolkit for computer-aided musicology, now with intuitive HTML/Javascript
interfaces. Some of the things music21j offers are:

  • The ability to visualize and hear changes in Streams quickly (using Vexflow and MIDI.js)
  • Connections (via Web Midi or JazzSoft plugin) to MIDI devices.
  • Music theory and analysis modules at the level of music21 ca. 2012
  • A repository of modules such as metronomes, keyboards, and automatic transcribers.

Though it does not have all the power of Music21 Python, music21j can help with
a number of research problems in music history and theory. The introduction to the
Python package will say more about it (it's better documented). The "namespaces"
tab above will give introductions to some of the features of music21j. At this
point we're focusing on documenting usage; developer docs will come

Music21j requires your users to have a relatively recent web browser -- the project
targets browsers no more than two years old.
Safari 9+, Chrome since 2015 (v.32+), Edge 14+, or Firefox since 2014 (v. 26+).
Internet Explorer 11+ is currently supported, though timing of playback can be a bit off, but
support for it will be removed soon. Microsoft Edge is the only major desktop browser for which
there is no support for MIDI devices.


This README appears in both the GitHub home page and the documentation
home page; to make the following links work, go to the documentation
page at .

Begin at the music21 namespace (click the link or use the
menu above), or start with
a specific one such as music21.note or
or a Class such as music21.note.Note or

(Ignore "Modules" they're not useful and duplicate the namespace pages).


Install by downloading a copy of the music21 code to your own webserver.

% npm install music21j

If this line (npm install) doesn't work, download the
latest version of node.js from

A guide to installing music21j on Windows would be appreciated.

The files in music21j are best viewed by running your own
webserver (rather than using file:///... links). We've
included a small script to start you up:

% cd ~/git/music21j
% grunt webpack
% python

Then navigate to http://localhost:8000/testHTML/ for some demos.

To use music21j in your own page, place in a html page like this (this assumes that you're
using the python server above).

<html lang="en">
<title>music21 test</title>
   <script src="/node_modules/music21j/releases/music21.debug.js">
   const n = new music21.note.Note('F#');
   const s = new;


0.9.15 alpha


Music21j is released under the BSD 3-Clause License. Essentially you
can do with it what you want so long as you leave in my copyright statements
and do not represent that I endorse your product.

Or you can choose to use the GNU Lesser Public License if for some reason
that suits your project better.


Thanks to the following packages (among others) for making music21j possible:

  • Vexflow - music notation in HTML5
  • midicube - audio processing of MIDI based on MIDI.js
  • Jazzsoft - plug-in for accessing MIDI in the browser in the absence of WebMIDI Api.
  • jQuery - easy manipulation of HTML DOM.
  • qUnit - testing framework
  • jsdoc - makes this documentation possible

Music21j in the Music and Theater Arts section at MIT.
The Python version of music21 was supported by grants from
the Seaver Institute and the National Endowment for the Humanities.

Dev Notes

Build with

$ grunt webpack

Before building, every once in a while run (in the music21j directory)


and if it looks like something to update, run

npm-check-updates --upgradeAll
npm update

Build documentation with:

grunt jsdoc

The template is specified in jsdoc-template/jsdoc.conf.json

These docs will be changing as we are moving from rollup to grunt in preparation
for v. 1.0 release.

Music21j, Copyright © 2013-2021 Michael Scott Asato Cuthbert.
Documentation generated by JSDoc 3.6.3 on Wed Jul 31st 2019 using the DocStrap template.