Importing Music into LilyPond

Imagine this scenario: you agree with the title of this blog and think LilyPond makes scores of beauty – in fact even better than the notation program you’re currently using. But migrating to LilyPond is not just like moving to another country, it’s like moving to another planet. What if you could just try out the “LilyPond appearance” with your latest [insert-your-current-notation-program]-score and then take it from there? The good news is that you can import your score into LilyPond – hopefully without greater efforts. This post will guide you through one way of doing this – using MusicXML as an intermediate file format.


There are three prerequesites for successfully following this post: having installed LilyPond itself, the LilyPond editor Frescobaldi, and – of course – an existing MusicXML file.

Most notation programs today can export to MusicXML files. There can of course be exceptions to this, but chances are very good that you can export a score to a MusicXML file from your current notation program. If you don’t know how to do that you will find an example file later on in this post.

Without LilyPond the idea of converting a score to LilyPond wouldn’t make much sense, would it? So you should go to LilyPond’s website where you’ll find installable packages with installation notes for Windows, Mac and Linux. [If you’re running Linux you can also install the lilypond package through your favorite package manager, but this may not give you the latest stable release, which is 2.16.2 as of the time of writing this post.]

When you have installed LilyPond you may be irritated that you don’t find a program in your application menu or desktop to open.
This is because LilyPond is a command line program that doesn’t have a graphical user interface to edit edit scores but rather reads in text input files and compiles them to beautiful scores.
So you need an editor to work on your text files. While you can do that with virtually any text editor I recommend you install Frescobaldi.
Using Frescobaldi as your editing environment to LilyPond is not actually necessary, neither in general nor for the import of MusicXML files, but it is recommendable because this is the editing environment which will give you the smoothest transition to the mentioned “other planet”. If you’re not fluent with the command-line/terminal (or don’t even know what the command-line or terminal is) you’ll know that this recommendation is for you. And of course this guide is using Frescobaldi.
The download page on the website offers a full Windows installer, links to installation instructions for Mac OS X and instructions for installation under Linux.
You can also install Frescobaldi through the package archives of most Linux distributions, but these will most likely contain older versions that don’t contain the MusicXML import interface.

Unfortunately it is beyond the scope of this post to guide you through these prerequisites in more detail. If you’re having problems with these initial steps feel free to post comments or use the contact link at the top of the page. Please include information of your operating system and or the notation program you export from, and we’ll find some useful links to more information about this.

Ok, so given that you have these prerequisites in place lets take a closer look at Frescobaldi and its MusicXML import.


Supplied with LilyPond is a little program called musicxml2ly which as the name implies does the conversion from a MusicXML file to a LilyPond .ly file. Just like LilyPond itself it doesn’t have a graphical user interface, i. e. it is a command-line tool.

As of Frescobaldi version 2.0.11 you can run musicxml2ly from within the graphical environment (just like you can run LilyPond), as a convenient import dialog. When you start Frescobaldi (especially if you had installed it earlier), please note the version number on the startup screen to ensure you have version 2.0.11 or later. Without this you cannot follow the next steps.

Import settings

In Frescobaldi’s main menu choose File->Import->Import MusicXML. Now it’s time to find your MusicXML file in the file dialog. This first part should be trivial for an experienced computer user as yourself ;-).

Next you are confronted with a dialog allowing you to set some options for the import process:

The import dialog with all options checked.

The import dialog with all options checked.

musicxml2ly has several (command line) options, but only some of the more important ones are accessible through UI elements in the import dialog. One reason is that some things can be easily done in Frescobaldi after import anyway, for example changing the note language. The other is that you can add options manually if you know what you’re doing (see below). Although you could certainly get away with skipping the options here and go straight for the import button (which says Run musicxml2ly), there are a few things to consider – so let’s take a quick look at the different options:

  • No articulation directions:
    The musicXML file might contain information about on which side of the note you have put your articulations. This information is retained as long as you don’t check this option.
  • No rest positions;
    In your original score you might have moved a rest to a different position or the musicXML file might for whatever reason contain information about the position of rests. This information is retained as long as you don’t check this option.
  • No page layout:
    The musicXML file might contain much information about the layout of the score in the original program.
    But only some overall page layout settings can be converted automatically, including line breaks and page breaks.
    If you check this option layout information is ignored.
  • Auto beaming:
    With this option the beaming information is ignored and LilyPond’s automatic beaming is used instead.

To let LilyPond do its job freely and to actually avoid some possible problems, I recommend checking at least the first three options.
If you want to try out LilyPond’s engraving capabilities it wouldn’t make sense to use layout decisions of your original program.
Maybe the articulation placement, the rest positions or the page layout as integral part of your editorial process, in that case you should of course uncheck the respective options.
The beaming is a somewhat more involved question. You can tell LilyPond to apply the beaming automatically, according to rules based on the time signature. Of course you can override this automatic beaming for each beam individually – which is dead easy – or you can modify the rules for any given time signature – which is more involved but possible.
Except for text based music it is usually better to check this box too, use LilyPond’s automatic beaming and change any individual beams later. But if you don’t like the results or if you have put significant effort in the beaming in your original score you may consider leaving that box unchecked.

Below the checkboxes there’s a text box with some cryptic text.
This represents the command which to invoke musicxml2ly with.
One tip for the more experienced reader: if you’re missing some of musicxml2ly‘s options, add it manually in this text box.

If you like to check out the different options in more detail, here is a test file which includes articulation directions, rest positions, page layout and beaming information: import-test.xml.

Post import

So, you made your choices and the import completed successfully. Now we can get a little more acquainted with Frescobaldi.

The source code of the test file after import with all options checked.

The source code of the test file after import with all options checked.

To the left you now have the newly imported LilyPond ly-file. Next step is to actually run LilyPond with that file. In the menu bar, somewhere in the middle, you can see the LilyPond menu. Here you have several so-called engraving options. I suggest that you memorize the keyboard shortcut (ctrl+m) for the first variant Engrave (Preview) and use that regularly while working on a score. When you are pleased with the result and are doing the final version you get back to this menu and choose Engrave (publish). When you run LilyPond the score should appear to the right.
The music view after import of the test file (with all options checked) and engraving.

The music view after import of the test file (with all options checked) and engraving.

I will not go deeper into the mysteries of Frescobaldi and LilyPond here, but only leave you with some tips on how to make some quick changes of the score. If the information about the title and composer are missing from the score, that information could be added in the \header section near the top of the file. Insert that information inside the curly brackets, for example:

header {
  title = “Symphony no. 40composer = “W. A. Mozart}

For more information on titling please refer to the manual.

If you didn’t check the option to ignore page layout you might be disappointed with the result.
As said earlier this would mean that LilyPond has to respect page and line breaking, which may interfere considerably with what LilyPond would have done by itself.
What you could do is delete the whole section which looks something like this:

#(set-global-staff-size 18)
paper {
  paper-width = 21.0cm
  paper-height = 29cm
  top-margin = 1.0cm
  bottom-margin = 2.0cm
  left-margin = 1.0cm
  right-margin = 1.0cm

This section is the result of trying to convert the page layout of the MusicXML file.
Removing it would be equivalent to importing with the option No page layout checked, but you will still have the explicit line and page breaks.
To remove them manually simply search for \break and \pageBreak commands in the generated LilyPond source code and delete them.
Alternatively to completely removing the section you could try changing some of the settings, for example the global staff size.

One final note: musicxml2ly can sometimes fail to complete the import.
Or the import might go through but then LilyPond will not be able to compile the file.
If this happens and you have no idea what went wrong or how to fix things, sadly neither do I at this point.
It could be any of several potential problems because the exchange of files through MusicMXL isn’t perfect yet (which is also true with other applications – the quality of MusicXML import and export is always a topic in different programs’ support forums).
But I have still one advice that might help; you could try to import the file in another notation program and do a new export from there.
There are a few free notation program that can be handy in this case.

I wish you good luck and lots of fun with your first steps exploring LilyPond and it’s world 🙂

11 thoughts on “Importing Music into LilyPond

  1. Urs Liska

    One thing that Peter is withholding from us: He himself is the one who is responsible for adding this functionality to Frescobaldi 😉

  2. Simon

    Hi Peter,

    Thanks for this post – very useful as I am planning on converting to lilypond soon. I would be importing some old scores that are in MusicXML 1.0 version. Will they be compatible with the method you describe?


    1. Peter Bjuhr Post author

      Hi Simon,

      the importer works mostly very well so you should be able to import your scores. But the import options have been changed and expanded a bit in later versions of Frescobaldi so the description in the post can perhaps be somewhat confusing! I should probably write a new post about that…

  3. Rohit

    Hi Peter,

    Thank you for the explanation in the blog. I was wondering if it is possible to convert ly files to musicxml and if it could be done through command prompt/ terminal using frescobaldi?


    1. Peter Bjuhr Post author

      Hi Rohit,

      thanks for the comment!

      The MusicXML export is under development and is still experimental.

      If you want to use it during a normal run of Frescobaldi you have to enable the experimental features in the preferences (Preferences -> General Preferences -> Experimental features).

      But your wish was to use it through the command prompt/terminal. In that case take a look at the Python-ly package (see

      I hope to soon return with a new post about the MusicXML export feature.

      1. Rohit

        Thank you for your reply. I downloaded the package and got it running. I look forward reading your blog about the export feature.


    1. Peter Bjuhr Post author

      There are some software that can do this. Especially related to scanning and recognizing sheet music. Unfortunately I lack the overview over this field so I’m afraid I can’t guide you further.


Leave a Reply

Your email address will not be published. Required fields are marked *