What Is MusicXML?
MusicXML is the standard file format for representing Western music notation in a machine-readable, software-independent way. Originally developed by Michael Good at Recordare LLC and first released in 2004, it is now maintained by the W3C Music Notation Community Group and published as MusicXML 4.0 (2021). The format is the de facto standard for exchanging sheet music between different notation software applications — when you import a score from Finale into MuseScore, or export from Sibelius to Guitar Pro, MusicXML is the bridge.
The format name reflects its nature: it is an XML-based format specifically for music notation — not audio (that would be MIDI or WAV), but the visual representation of pitches, rhythms, dynamics, articulations, and all the symbolic elements that appear on a printed score.
File Types: .xml and .mxl
MusicXML files come in two variants:
| Extension | Type | Description |
|---|---|---|
.xml |
Uncompressed | Plain UTF-8 XML, human-readable, larger |
.mxl |
Compressed | ZIP archive containing the XML plus a MIME manifest; typically 80–90% smaller |
Always prefer .mxl for distribution — a 500 KB XML score compresses to ~50 KB. The .mxl container follows the Open Packaging Convention (similar to DOCX/XLSX). Unzip any .mxl file to inspect its contents.
Score Document Structure
MusicXML uses one of two root element structures:
score-partwise (most common — preferred by Finale, MuseScore, Sibelius):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC
"-//Recordare//DTD MusicXML 4.0 Partwise//EN"
"http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="4.0">
<work>
<work-title>Symphony No. 5</work-title>
</work>
<identification>
<composer>Ludwig van Beethoven</composer>
<encoding>
<software>MuseScore 4.3</software>
<encoding-date>2024-03-15</encoding-date>
</encoding>
</identification>
<part-list>
<score-part id="P1">
<part-name>Violin I</part-name>
</score-part>
<score-part id="P2">
<part-name>Violin II</part-name>
</score-part>
</part-list>
<part id="P1">
<measure number="1">
<!-- measure contents -->
</measure>
</part>
</score-partwise>
score-timewise: the transpose — primary organization is by measure, then part. Rarely used by notation software but occasionally produced by musicological analysis tools.
The Measure: Where Music Lives
Every musical event is encoded within a <measure> element:
<measure number="1">
<!-- Attributes establish the musical context -->
<attributes>
<divisions>4</divisions> <!-- quarter note = 4 divisions -->
<key>
<fifths>-3</fifths> <!-- 3 flats = Eb major / C minor -->
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type> <!-- 4/4 time -->
</time>
<clef>
<sign>G</sign>
<line>2</line> <!-- treble clef on line 2 -->
</clef>
</attributes>
<!-- A dotted half note G4 -->
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>6</duration> <!-- 6 divisions = dotted half note (4+2) -->
<type>half</type>
<dot/>
<stem>up</stem>
<notations>
<dynamics><mf/></dynamics>
<articulations>
<accent/>
</articulations>
</notations>
</note>
<!-- A rest for one quarter note -->
<note>
<rest/>
<duration>4</duration>
<type>quarter</type>
</note>
<!-- A chord: E4 and C4 sounding simultaneously -->
<note>
<pitch><step>E</step><octave>4</octave></pitch>
<duration>4</duration><type>quarter</type>
</note>
<note>
<chord/> <!-- <chord/> = this note sounds with the previous one -->
<pitch><step>C</step><octave>4</octave></pitch>
<duration>4</duration><type>quarter</type>
</note>
</measure>
Pitch, Duration, and Rhythm
Pitch is specified as step (A–G) + octave (4 = middle C octave) + optional alter (semitones: −1=flat, +1=sharp, 0=natural):
<pitch>
<step>B</step>
<alter>-1</alter> <!-- Bb -->
<octave>4</octave>
</pitch>
Duration is measured in divisions — a unit-free integer count defined by the <divisions> attribute. If <divisions>4</divisions>, then:
- Quarter note = 4 divisions
- Half note = 8 divisions
- Whole note = 16 divisions
- Eighth note = 2 divisions
- 16th note = 1 division
The <type> element gives the visual note type as a string ("whole", "half", "quarter", "eighth", "16th", "32nd", etc.) which may differ from <duration> when triplets or other tuplets are involved.
Dynamics, Tempo, and Expression
<!-- Dynamic marking -->
<direction placement="below">
<direction-type>
<dynamics><pp/></dynamics>
</direction-type>
</direction>
<!-- Tempo marking -->
<direction>
<direction-type>
<metronome parentheses="no">
<beat-unit>quarter</beat-unit>
<per-minute>120</per-minute>
</metronome>
</direction-type>
<sound tempo="120"/>
</direction>
<!-- Text expression -->
<direction>
<direction-type>
<words font-style="italic">dolce</words>
</direction-type>
</direction>
<!-- Crescendo hairpin -->
<direction placement="below">
<direction-type>
<wedge type="crescendo"/>
</direction-type>
</direction>
Analyzing Scores with Python (music21)
music21 (MIT) is the definitive Python library for computational musicology:
from music21 import *
# Load a MusicXML file
score = corpus.parse('bach/bwv66.6') # from built-in corpus
# or from file:
score = converter.parse('beethoven_sym5.xml')
# Basic score info
print(score.metadata.title)
print(score.metadata.composer)
parts = score.parts
print(f"Number of parts: {len(parts)}")
print(f"Part names: {[p.partName for p in parts]}")
# Get all notes in part 0 (e.g. Soprano)
soprano = parts[0]
notes = soprano.flat.notes
print(f"Note count: {len(notes)}")
# Iterate over notes
for n in notes[:10]:
if isinstance(n, note.Note):
print(f" {n.nameWithOctave:5s} duration={n.duration.type:8s} offset={n.offset}")
elif isinstance(n, chord.Chord):
print(f" Chord {n.pitches} duration={n.duration.type}")
# Key analysis (Krumhansl-Schmuckler algorithm)
key = score.analyze('key')
print(f"Detected key: {key}")
# Count intervals
from music21 import interval
intervals = []
notes_list = list(soprano.flat.notes)
for i in range(len(notes_list) - 1):
if isinstance(notes_list[i], note.Note) and isinstance(notes_list[i+1], note.Note):
iv = interval.Interval(notes_list[i], notes_list[i+1])
intervals.append(iv.name)
from collections import Counter
print(Counter(intervals).most_common(5))
# Export to MIDI
score.write('midi', fp='output.mid')
# Export to Lilypond for PDF rendering
score.write('lily.pdf', fp='output.pdf')
# Render as PNG (requires MuseScore in PATH)
score.write('musicxml.png', fp='output.png')
Converting MusicXML
MusicXML → MIDI: All major notation programs export MIDI from MusicXML. music21: score.write('midi', fp='out.mid'). MIDI is lossy — it loses all visual notation data (slurs, articulation types, text expressions, layout).
MusicXML → PDF: MuseScore command-line: musescore3 input.mxl -o output.pdf. LilyPond can render from MusicXML via musicxml2ly converter.
MusicXML → MEI: Music Encoding Initiative (MEI) is the scholarly counterpart to MusicXML, used in digital humanities. Verovio (C++/Python/JS) renders both MEI and MusicXML to SVG.
Software That Uses MusicXML
| Software | Role | MusicXML Support |
|---|---|---|
| MuseScore | Open-source notation editor | Native read/write |
| Finale | Professional notation | Read/write since 2001 |
| Sibelius | Professional notation | Read/write (import via plugin pre-2023) |
| Dorico | Steinberg notation | Native read/write |
| Guitar Pro | Tab notation | Read/write MusicXML |
| Notion | iOS/macOS notation | Read/write |
| Flat.io | Web-based notation | Read/write |
| music21 | Python analysis | Read/write |
| Audiveris | Music OCR (OMR) | MusicXML output from scanned scores |
Audiveris is particularly notable — it performs Optical Music Recognition (OMR), converting scanned sheet music images (JPEG, TIFF) into MusicXML using machine learning and traditional computer vision.
Related conversions
Audio format pairs that come up most often: