Skip to main content
v2026.11,858 entries · CC-BY 4.0

MusicXML: File Format, Structure and How to Open It

MusicXML file format explained: annotated structure, .musicxml vs .mxl, opening files in Python, and preservation guidance for researchers.

Written and maintained by CASRAI Editorial Board

Last updated

MusicXML is an open, XML-based file format for exchanging Western music notation between programs. It stores what a score means (pitches, durations, key and time signatures, parts) rather than how a printed page looks. Researchers in musicology, music theory and digital humanities meet it when they export an edition from a notation editor, deposit a score in a repository, or load notated music into analysis code. After reading this guide you should be able to read a MusicXML file by eye, tell .xml, .musicxml and .mxl apart, open and inspect a compressed file with a few lines of Python, and describe the format correctly in a data-management plan.

What is MusicXML?

The W3C Music Notation Community Group describes MusicXML 4.0 as “a standard open format for exchanging digital sheet music” (Final Community Group Report, 1 June 2021). Two details matter for precise citation. First, the specification is a Community Group report: it is not a W3C Standard and is not on the W3C Standards Track. Second, it is an exchange format, so any one program may read or write only part of it.

The Library of Congress Sustainability of Digital Formats entry (FDD 000358) adds the history. Michael Good created the format at Recordare, with version 1.0 released in January 2004. MakeMusic acquired Recordare in late 2011, and the W3C Music Notation Community Group has maintained the specification since July 2015. Versions and release dates recorded by the Library of Congress are below.

Version Date recorded Note
1.0 January 2004 First release
1.1 May 2005
2.0 June 2007 Introduced the compressed .mxl package
3.0 August 2011
3.1 December 2017 Files from versions 1.0 to 3.0 are valid 3.1 files
4.0 1 June 2021 W3C Community Group Report

The format was defined first with DTDs and, since 2008, also with W3C XML Schema. Because it is plain XML, it follows the same general principles as other research XML formats; see the CASRAI guides to JATS XML and to JSON versus XML for the surrounding concepts.

MusicXML file structure explained

A MusicXML document has one root element. The root is score-partwise (music organised by part, then by measure), score-timewise (organised by measure, then by part) or opus (a collection of scores). The partwise form is the one most programs write. Inside it, a part-list declares each instrument, and one part element per instrument holds its measure elements.

A minimal file, element by element

The W3C “Hello World” tutorial gives the smallest useful score: one part, one measure, one note. In outline:

<score-partwise version="4.0">
  <part-list>
    <score-part id="P1"><part-name>Music</part-name></score-part>
  </part-list>
  <part id="P1">
    <measure number="1">
      <attributes>
        <divisions>1</divisions>
        <key><fifths>0</fifths></key>
        <time><beats>4</beats><beat-type>4</beat-type></time>
        <clef><sign>G</sign><line>2</line></clef>
      </attributes>
      <note>
        <pitch><step>C</step><octave>4</octave></pitch>
        <duration>4</duration>
        <type>whole</type>
      </note>
    </measure>
  </part>
</score-partwise>
Element What it records
score-part id="P1" and part id="P1" The same identifier links the instrument declared in part-list to the music in its part.
divisions How many duration units make up one quarter note.
key / fifths Position on the circle of fifths: positive numbers count sharps, negative numbers count flats, 0 is C major.
time The time signature, here 4/4.
clef Clef sign and staff line: G on line 2 is the treble clef.
pitch (step, octave) Note name and octave number; here C in octave 4. Sharps and flats are added with an alter child.
duration Length in the units set by divisions.
type The written note shape (here whole). It is stored separately from duration.

The tutorial also notes that the children of note must appear in a set order: pitch, then duration, then type.

Worked example: reading the duration arithmetic

With divisions = 1, one quarter note equals 1 duration unit. The note has duration = 4, so it lasts 4 ÷ 1 = 4 quarter notes, which is a whole note and fills the 4/4 measure exactly (4 beats × 1 quarter note per beat = 4 units). This matches the type of whole. If the file set divisions to 2, an eighth note would have duration 1 and a quarter note duration 2; the same whole note would then need duration 8. Always divide duration by the current divisions value before comparing lengths across files.

.musicxml vs .mxl vs .xml: file extensions and media types

Form What it is Extension Media type
Uncompressed A single XML document .xml through version 3.0; .musicxml from 3.1 (the W3C 4.0 tutorial recommends .musicxml) application/vnd.recordare.musicxml+xml
Compressed A ZIP package (DEFLATE, UTF-8 file names) .mxl, from version 2.0 application/vnd.recordare.musicxml

What is inside an .mxl file?

An .mxl file is a ZIP archive. It contains META-INF/container.xml, whose rootfile elements give a full-path to each file; the first rootfile is the MusicXML score. Further rootfile entries may point to alternate renditions of the same score, such as a PDF. From version 3.1 the package also carries a mimetype file as its first entry, stored uncompressed.

How to open a MusicXML file

Most notation editors and score viewers import MusicXML, so the simplest route is to open the file in one. The Library of Congress lists browser rendering (for example with OpenSheetMusicDisplay) and screen-reader access (for example through MuseScore) among documented uses. For inspection in code, the Python standard library is enough. This snippet reads the root score from an .mxl file and converts one note’s duration to quarter notes; it was run against a package built from the Hello World example above and printed C4 4.0.

import zipfile
import xml.etree.ElementTree as ET

with zipfile.ZipFile("score.mxl") as z:
    container = ET.fromstring(z.read("META-INF/container.xml"))
    root_path = container.find(".//rootfile").get("full-path")
    score = ET.fromstring(z.read(root_path))

divisions = int(score.find(".//divisions").text)
for note in score.iter("note"):
    pitch = note.find("pitch")
    if pitch is None:
        continue  # rests have no pitch
    name = pitch.find("step").text + pitch.find("octave").text
    print(name, int(note.find("duration").text) / divisions)

The snippet assumes one divisions value per file. Real scores can change divisions in later measures, so a production script should track the most recent value measure by measure.

Common mistakes

  • Treating it as a page image. MusicXML encodes score semantics, not printed page layout, so line breaks and spacing may differ between programs.
  • Assuming a perfect round trip. The Library of Congress notes that fidelity is not guaranteed when a file moves between programs. Compare the exported file with the original before relying on it for analysis.
  • Comparing duration values without divisions. The same number means different lengths under different divisions.
  • Confusing the three extensions. A .xml file may be an old MusicXML export or any other XML; check the root element.
  • Calling it a W3C Standard. It is a W3C Community Group report.

How to cite and deposit MusicXML files

For preservation, the Library of Congress lists MusicXML as a preferred format for the digital scores it acquires, and notes the format has no encryption. State in your data-management plan the version (the version attribute on the root element), the extension used and the software that produced the file. Give each deposited score a persistent identifier and descriptive and technical metadata; the guide to types of metadata shows how these layers differ. For a citable description of the format itself, cite the specification as: W3C Music Notation Community Group. (2021). MusicXML Version 4.0 (Final Community Group Report, 1 June 2021). https://www.w3.org/2021/06/musicxml40/. Musicologists who work with scores will find the wider discipline outlined in what is musicology; a comparable format guide for bibliographic data is the RIS file format.

FAQ

What does MusicXML stand for and who maintains it?

It is an XML format for music notation. The W3C Music Notation Community Group has maintained it since July 2015; its editor for version 4.0 was Michael Good of MakeMusic.

Is MusicXML the same as MIDI?

No. MusicXML records notation (note spelling, clefs, key and time signatures, parts). It is a notation exchange format: it encodes how music is written, not a recording of a performance.

What is the difference between .musicxml and .mxl?

.musicxml is the uncompressed XML document; .mxl is a ZIP package containing it plus a META-INF/container.xml pointing to the score.

Can I open a MusicXML file in a text editor?

An uncompressed file, yes: it is plain XML text. An .mxl file must be unzipped first.

Is MusicXML good for long-term preservation?

The Library of Congress lists it as a preferred format for digital scores, but warns that round-trip fidelity between programs is not guaranteed, so keep the original and any rendered PDF alongside it.

Sources

  • W3C Music Notation Community Group. MusicXML Version 4.0, Final Community Group Report, 1 June 2021. https://www.w3.org/2021/06/musicxml40/ (read 8 November 2026).
  • W3C. MusicXML 4.0 tutorial: “Hello World” and “Compressed .MXL Files”. https://www.w3.org/2021/06/musicxml40/tutorial/ (read 8 November 2026).
  • Library of Congress. “MusicXML (Music Extensible Markup Language)”, Sustainability of Digital Formats, FDD 000358. https://www.loc.gov/preservation/digital/formats/fdd/fdd000358.shtml (read 8 November 2026).

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about MusicXML: File Format, Structure and How to Open It

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →