MusicXML validator
When MuseScore, Finale, Sibelius or Dorico says a file is “not a valid MusicXML file”, or imports it with parts or notes missing, the file usually breaks one of MusicXML’s rules. Open it here to see every problem with its line and column, in plain words and with the fix. The validator checks the file against the official MusicXML 4.0 schema, which also covers older files: valid MusicXML 1.0 to 3.1 files are also valid 4.0 files. It reads compressed .mxl files, and summarizes what the score contains. It runs entirely in your browser: the file is not uploaded.
Validator
Or drag a file onto this box, or try a sample:
Paste MusicXML text instead
Result
Schema errors
Beyond the schema
| ID | Part | Instrument | MIDI program | Measures | Notes | Written range | Staves |
|---|
What the validator checks
- Readable bytes. The file must be UTF-8 (or UTF-16, or the encoding its first line declares). A score saved as Windows-1252 without saying so fails here, often on an accented name in the title or lyrics.
- Well-formed XML. Every tag closed and nested properly, attribute values quoted and not repeated, and special characters escaped. If this fails, no program can open the file, so the validator stops and shows the first problem.
- The MusicXML schema. Every element is allowed where it appears and in the required order; required elements and attributes are present; values are in range and spelled exactly (
quarter, notQuarter); numbers use a decimal point; IDs are unique and every<part id>matches a<score-part>. - The .mxl container. For compressed files: the
META-INF/container.xmlthat names the score, the file it points to, and themimetypeentry. - Beyond the schema. Parts listed in
<part-list>but never written, parts with different numbers of measures, a missingversionattribute, timewise scores that most programs cannot import, and measures whose notes do not add up to the time signature (the measure checker lists each one).
The summary shows the title, credits, the program that wrote the file, the parts with their instruments, MIDI programs, measure and note counts and written range, and the key, time and tempo marks.
Fixing the most common MusicXML errors
“A bare & is not allowed” (not a valid MusicXML file)
An ampersand in a title, a part name, lyrics or a rights line must be written &. A raw &, as in <work-title>Rock & Roll</work-title>, makes the whole file unreadable, and programs report it as a fatal error at a line and column. The same applies to <, which must be <. Fix it in a text editor at the reported line, or rename the title in the program that exported the file and export again.
“… is in the wrong place”: element order
MusicXML fixes the order of child elements. Inside a <note> it is: <grace> or <cue>, <chord>, the <pitch>, <unpitched> or <rest>, <duration>, <tie>, <instrument>, <voice>, <type>, <dot>, <accidental>, <time-modification>, <stem>, <notehead>, <staff>, <beam>, <notations> and <lyric>. Inside a <pitch> the order is step, alter, octave. Hand-edited files and small converters often get this wrong; the validator says where the element belongs (“It belongs after <duration>”). See element order inside a note.
Wrong values: case, note names and decimal commas
- Values are case-sensitive:
<type>quarter</type>,<stem>up</stem>,yesandno. <step>takes English note names A to G. The German H is B.- Numbers need a decimal point:
tempo="120.5", never120,5(a common result of a program running in a European locale). Fractions are not allowed either: 0.25, not 1/4. <duration>and<divisions>must be positive;<octave>runs from 0 to 9.
Parts that do not match the part list
Every <part id="P1"> needs a matching <score-part id="P1"> in <part-list>, and each ID may be used once. When a part is missing from the list, programs drop its music or refuse the file. A <score-part> without music is allowed by the schema, but shows up as an empty staff, so the validator flags it.
Attributes a program does not recognize
Some programs write their own attributes or misspell standard ones (colour for color). They are schema errors. Notation programs differ in how strictly they read files: some skip what they do not understand, others stop. A file that passes the validator is one that every program should read the same way.
Compressed .mxl files that do not open
An .mxl file is a ZIP archive. Programs find the score through META-INF/container.xml; if that file is missing, or names a file that is not in the archive, they cannot open it. If you rebuild an archive by hand, put the container.xml in a META-INF folder and make its <rootfile full-path> match the score’s file name. See compressed MusicXML.
Valid, but still imports wrongly?
The schema checks structure, not music. A file can be valid and still hold a measure with one beat too many, a tie with no end, or a transposition the importing program reads differently. For timing, the most common cause of extra rests, use the measure duration checker (its summary already appears under “Beyond the schema”). To hear what the file actually contains, convert it with the MusicXML to MIDI converter; why MusicXML imports with extra rests explains the usual fixes.
How this validator works, and how it was tested
The rules come from the official MusicXML 4.0 XSD published by the W3C Music Notation Community Group (schema listings). A build script compiles the schema into a compact model of element orders, attributes and value types; in the browser each element’s content is matched against its model with a small state machine. Element positions come from a strict XML reader that records where each tag starts.
Before release, the results were compared with libxml2, the XML library behind xmllint:
- 265 real files (the LilyPond MusicXML test suite and the OpenSheetMusicDisplay test scores): the same valid or invalid verdict for 264, and the same error lines for every file both found invalid.
- 533 copies of those files with random damage (elements deleted, swapped, renamed or duplicated, and bad values and attributes): the same verdict for 529, and the same first error line for all 396 that both found invalid.
- 60 files with broken XML (bare ampersands, unclosed tags, control characters, duplicate attributes, invalid UTF-8): the same answer to “is this well-formed?” for all 60, and the same error line for all 53 broken ones.
The differences are deliberate: the XSD standard requires every ID reference to point to an existing ID, which libxml2 does not check, so this validator reports a <part> without a <score-part> and libxml2 does not. Like libxml2, it reports only the first ordering error inside each element, because everything after a misplaced element tends to fail too. The validating code is musicxml-validator-core.mjs.
Validating MusicXML on your own computer
To check many files, or as part of a build, validate with xmllint (part of libxml2: included with macOS, and in the libxml2-utils or libxml2 package on Linux). Download the schema files musicxml.xsd, xml.xsd and xlink.xsd from the W3C listing into one folder, change the two schemaLocation URLs at the top of musicxml.xsd to the local file names, then run:
xmllint --noout --schema musicxml.xsd score.musicxml
It prints score.musicxml validates or one line per error. For a compressed file, unzip it first and validate the file named in META-INF/container.xml. In Python, the lxml library does the same:
from lxml import etree
schema = etree.XMLSchema(etree.parse("musicxml.xsd"))
doc = etree.parse("score.musicxml")
print(schema.validate(doc), [(e.line, e.message) for e in schema.error_log])
Sample files
- validator-common-errors.musicxml: one flute measure with five common mistakes: a decimal comma in a tempo, the German note name H,
<type>before<duration>, acolourattribute andQuarterwith a capital Q. The validator reports all five, one per line. - validator-ampersand.musicxml: the title “Rock & Roll” with an unescaped ampersand, so the file is not well-formed XML.
- Valid files to compare with: the MusicXML example files, including a compressed
.mxl.