Categories We Write About

Convert Evernote exports to structured data

To convert Evernote exports to structured data, you’ll typically work with ENEX files (Evernote’s XML export format). These files contain metadata and content for each note, structured in XML. The goal is to parse these and convert them into structured formats like JSON, CSV, or a database-friendly format.

Step-by-Step Guide to Convert Evernote Exports to Structured Data


1. Export Notes from Evernote

  • Open Evernote.

  • Select the notes or notebook.

  • Go to File > Export Notes….

  • Choose Evernote XML Format (.enex).


2. Understand the ENEX Structure

Each ENEX file has:

xml
<en-export> <note> <title>Note Title</title> <content><![CDATA[<?xml version="1.0"?><!DOCTYPE en-note ...>Content Here</en-note>]]></content> <created>20220101T120000Z</created> <updated>20220102T130000Z</updated> <tag>Tag1</tag> <tag>Tag2</tag> <note-attributes> <author>John Doe</author> </note-attributes> <resource>...</resource> </note> ... </en-export>

3. Use a Parser to Extract Data

Python is a common tool for this. Here’s a basic example:

python
import xml.etree.ElementTree as ET import json def parse_enex(enex_path): tree = ET.parse(enex_path) root = tree.getroot() namespace = {'en': 'http://xml.evernote.com/pub/enml2.dtd'} notes = [] for note in root.findall('note'): title = note.findtext('title') content_raw = note.findtext('content') created = note.findtext('created') updated = note.findtext('updated') tags = [tag.text for tag in note.findall('tag')] author = note.find('note-attributes/author') author = author.text if author is not None else None notes.append({ 'title': title, 'content': content_raw, 'created': created, 'updated': updated, 'tags': tags, 'author': author }) return notes parsed_data = parse_enex("your_notes.enex") with open("notes.json", "w") as f: json.dump(parsed_data, f, indent=2)

4. Optional: Clean HTML Content

The content field contains ENML (Evernote Markup Language), which is based on XHTML. You may want to extract plain text or HTML.

Use libraries like BeautifulSoup:

python
from bs4 import BeautifulSoup def extract_plain_text(enml_content): soup = BeautifulSoup(enml_content, 'html.parser') return soup.get_text(separator='n') # Apply to each note for note in parsed_data: note['text'] = extract_plain_text(note['content'])

5. Convert to CSV or Database Format

You can use pandas to convert the cleaned data to a CSV:

python
import pandas as pd df = pd.DataFrame(parsed_data) df.to_csv("notes.csv", index=False)

6. Storing in a Database (Optional)

You can also insert the data into a SQL database using sqlite3:

python
import sqlite3 conn = sqlite3.connect('notes.db') c = conn.cursor() c.execute('''CREATE TABLE IF NOT EXISTS notes (title TEXT, content TEXT, created TEXT, updated TEXT, tags TEXT, author TEXT)''') for note in parsed_data: c.execute("INSERT INTO notes VALUES (?, ?, ?, ?, ?, ?)", ( note['title'], note['content'], note['created'], note['updated'], ','.join(note['tags']), note['author'] )) conn.commit() conn.close()

7. Advanced: Handling Attachments

The <resource> element contains attachments (like images, PDFs):

xml
<resource> <data encoding="base64">...binary data...</data> <mime>image/png</mime> <resource-attributes> <file-name>image.png</file-name> </resource-attributes> </resource>

You can decode and save these using Python:

python
import base64 for resource in note.findall('resource'): mime = resource.findtext('mime') filename = resource.find('resource-attributes/file-name').text data = base64.b64decode(resource.findtext('data')) with open(filename, 'wb') as f: f.write(data)

Summary

  • Export notes as .enex.

  • Parse using Python or another XML tool.

  • Extract key fields: title, content, tags, created/updated dates, author.

  • Clean and convert ENML to plain text.

  • Output to structured format: JSON, CSV, or SQL database.

  • Optionally extract attachments.

This approach gives you full control to repurpose Evernote content into any system like Notion, Roam, Obsidian, or custom apps.

Share This Page:

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Comments

Leave a Reply

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

Categories We Write About