md2enex
is a command-line tool that converts a directory of markdown files to an Evernote .enex
export format, that can then be imported into Evernote.
python
verion 3.12 or later: Instructionspipx
: Instructionsmd2enex
with pipx
:pipx install git+https://github.com/karloskalcium/md2enex.git
md2enex [-o OUTPUT_FILE] DIRECTORY
Note: DIRECTORY
should be a directory containing all of the .md files you want to import. This does not work recursively, so all files must be in the top-level of the directory.
The resultant .enex
file can be imported into Evernote using the import feature.
You can get additional help by running:
md2enex -h
This tool uses pandoc
to convert Markdown to HTML, and then converts that HTML to ENML (stripping some tags in the process), and then embeds this into the ENEX import/export format created by Evernote.
I used Exporter
to export notes from Apple Notes app, and since Exporter
does not add newlines to Markdown, md2enex
uses the markdown+hard_line_breaks
option of pandoc
to ensure proper line spacing; if your Markdown line spacing is correct in the source Markdown files you may want to remove that option in the code.
Additionally, Exporter
adds the title of the note as a top-level header in the note itself. This is not needed in Evernote, so if the first line of a note is a <h1>
header, it is removed.
The HTML generated by the markdown will be validated against the Evernote DTD. If validation fails, the file will be skipped. Additionally, img
and figure
tags will be detected and if found, the file will be skipped, as embedded media is not supported by this converter.
A warning: Evernote can be finicky about notes; if notes have any unknown/unsupported tags in them, they can successfully import, and then they will disappear silently at some point (perhaps when they sync to the server?). So even though this tool tries to validate the import against the Evernote DTD, to be extra safe, check the number of notes at import, and confirm that same number of notes remains in Evernote after syncing/refreshing/closing/restarting. If notes disappear, it's probably because of some strange syntax that made its way from Markdown into the generated HTML and that Evernote does not accept.
Open an Issue. Pull requests welcome.
You can also ask a question in the discussions section.
This project uses Poetry for packaging and dependency management.
Most of the things you need to do are targets in the makefile.
make
to get a list of targetsmake unit-test
to run the testsmake lint
to run the ruff linter