Evernote notes can be exported from our Windows and Mac clients using two different output formats: HTML and ENEX.
HTML produces a web page (or series of web pages) containing all of the exported notes, as well as any included Resources (images, files, etc.). This format is useful for sharing Evernote content with just about anybody, even folks who don’t use Evernote. The Evernote software is not able to import notes exported as HTML.
ENEX produces an XML document that can be imported back into Evernote. In this post, we’re going to describe this format in detail.
Using ENEX export files
There are several potential uses for exported notes:
- Migrating data between accounts
- Archiving notes that you don’t want in your account and would rather not delete
While it may seem like a reasonable use case, developers should avoid creating or changing notes by manipulating ENEX files. Due to typos, incorrect formatting and simple human error, many types of errors can be introduced when modifying these files by hand. The Evernote API provides a simpler means of creating and modifying notes and is the preferred method for doing so.
The ENEX file format and specification
The ENEX file format is formally defined by version 3 of the Evernote Export doctype declaration. A note exported as ENEX is complete and can be imported back into Evernote exactly as it was exported; this includes all attached files, recognition information and tags (optionally).
Here is an example ENEX file. Let’s take a look at how the file is organized and what data it contains.
Below the XML declaration and the aforementioned doctype declaration, we have the en-export element. The export-date, application, and version attributes of en-export define the date and time the note was exported, the application where the export originated and the specific version of the exporting application. The first—and, in our example, only—child element of en-export is note (if multiple notes had been exported to this ENEX file, each would have its own note element). Within this element, we’ll find all of the data stored in the exported note:
- title contains the title of the note
- content encompasses the body of the note in its raw ENML form, wrapped in CDATA tags.
- created and updated describe the date and time the note was created and most recently updated, respectively.
- The export may contain zero or more tag instances; each instance represents a tag that was applied to the note before the note was exported.
- The note-attributes element may contain location information, if available (like latitude, longitude and altitude), as well as other data (including the note’s author, in this example).
For each Resource contained in the note, there will be a corresponding resource element within note which will be comprised of the following child elements:
- data is a base64-endcoded version of the Resource.
- mime is the MIME type of the Resource.
- width and height will be set if the Resource can be displayed inline (e.g., images and PDFs).
If there are any Resources in the note or notes being exported, a resource-attributes for each Resource will be present and, depending on the type of Resource, contain one or more optional child elements:
- source-url is the web URL where the note was originally clipped.
- If the device used to capture embeds it in the original file, the timestamp and file-name values will be set.
- The latitude, longitude, and altitude where the Resource was created.
- camera-make and camera-model for Resources originating from a camera that embeds such information in its photos.
- attachment is a boolean value controlling whether the Resource is displayed as an attachment or inline (if possible).
- application-data is a 4kb field where third-party developers can store data for their own purposes (restrictions apply; make sure to read the documentation before attempting to use this field).
As described in the Resources documentation, each Resource will be embedded in the content element using the en-media tag. Depending on the type of Resource, the en-media tag will include attributes that govern size, filename, and other visually-relevant information about the Resource. See the documentation for more information on constructing valid en-media elements.
- ENEX files do not represent how notes are stored within the Evernote service or applications; they are a portable export format that allows notes to be migrated in their entirety between systems and accounts.
- base64-encoded data can be converted back to its original form. Here’s a quick and dirty example of how to do this.
If you have any questions about the ENEX file format, drop us a line or leave a comment below!