music21
A Toolkit for Computer-Aided Musical Analysis and Computational Musicology.
What it is and what it does
music21 is a Python library for symbolic music analysis and computational musicology, developed at MIT since 2010. It provides tools to parse, analyze, and manipulate musical scores in formats like MusicXML and MIDI, enabling programmatic access to musical notation, pitch, rhythm, harmony, and other analytical properties. The library is built on standard scientific Python dependencies (numpy, matplotlib, joblib) and supports modern Python versions (3.11+).
Typical workflows involve loading scores from files or URLs, traversing their hierarchical structure to extract notes and measures, performing analytical operations (harmonic analysis, voice leading checks, statistical studies), and generating visualizations or new scores. It's commonly used in music education, research, and computational analysis projects where symbolic representation of music is more relevant than audio processing.
Use it for:
- Analyze harmonic progressions and voice leading in classical scores for music theory research.
- Extract melodic or rhythmic patterns from a collection of scores for statistical musicology studies.
- Programmatically generate or modify MusicXML scores based on algorithmic composition rules.
- Build educational tools that parse student compositions and provide automated feedback on notation or structure.
- Convert between MIDI and MusicXML formats for integration with other music software workflows.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
music21 is a Python toolkit for analyzing, processing, and computationally working with musical scores and MIDI data, supporting symbolic music representation and analysis workflows.
Yes, if you work with symbolic music notation, analysis, or computational musicology. Low install friction, active maintenance, no known vulnerabilities, and permissive licensing make it a safe choice. Not suitable if you need audio processing or real-time synthesis—music21 works with symbolic scores, not sound files.
Install
music21 on PyPI
pip
pip install music21uv
uv add music21poetry
poetry add music21Installing music21
Before you install
Low friction: pure Python wheel with 8 runtime dependencies (chardet, joblib, jsonpickle, matplotlib, more-itertools, numpy, requests, webcolors). Active maintenance with a commit from 2026-08-12 and a release 58 days prior.
License in practice
BSD-3-Clause permissive license. Free to use, modify, and distribute provided you retain the LICENSE file and copyright notice. Externally provided software and encoded musical scores in the corpus may carry separate licenses.
Quickstart
pip install music21
from music21 import converter, stream
# Load and analyze a score
score = converter.parse('path/to/score.musicxml')
for note in score.flatten().notes:
print(note.pitch, note.quarterLength)
Requires Python 3.11 or later.
Verify before relying
- Whether matplotlib is required for all use cases or only for visualization features.
- Whether external music notation software (e.g., MuseScore, Finale) is needed for rendering or playback.
- Performance characteristics when processing large scores or corpora.
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 8 — chardet, joblib, jsonpickle, matplotlib, more-itertools, numpy, requests, webcolors |
| Maintenance | actively maintained — 58 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 409,505/month — #6,871 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: music21-10.5.0-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
symusicsymusic parses and transforms MIDI and ABC…
permissive · top 15,000 on PyPI
pretty-midiProvides utilities for reading, modifying, and…
permissive · top 15,000 on PyPI
mir-evalmir_eval computes standard accuracy metrics for…
permissive · top 15,000 on PyPI
aubioaubio is a Python wrapper around a C library…
copyleft · top 15,000 on PyPI
librosalibrosa provides audio and music signal…
permissive · top 5,000 on PyPI
midoMido provides a Python library for creating,…
permissive · top 5,000 on PyPI
pylastpylast provides a Python interface to Last.fm…
permissive · top 15,000 on PyPI
basic-pitchBasic Pitch converts audio files to MIDI…
unclear · top 15,000 on PyPI
syncedlyricsFetches synchronized lyrics in LRC format for…
permissive · top 15,000 on PyPI
music-assistant-modelsProvides shared data models for Music…
permissive · top 15,000 on PyPI