enex-io
v0.2.0
Published
High-performance parser and generator for Evernote/Apple Notes (.enex) files.
Maintainers
Readme
enex-io
High-performance parser and generator for Evernote & Apple Notes (.enex) files.
A lightweight Node.js library and CLI tool that reads and writes .enex files — the format used by both Evernote and Apple Notes. Ideal for migrations, backups, and any pipeline that needs to move notes in or out of the Apple / Evernote ecosystem.
Features
- Parse
.enexarchives into structured JSON objects. - Generate valid
.enexfiles from JSON, including proper<created>and<updated>timestamps, tags, and HTML content. - Handles XSS-safe XML escaping for titles and content.
- Dates are converted to and from Evernote's compact UTC format (
YYYYMMDDTHHmmssZ) automatically.
Installation
# Install globally for CLI usage
npm install -g enex-io
# Install as a project dependency
npm install enex-ioUsage
CLI
# Parse ENEX → JSON
enex-io to-json my-notes.enex
# Output: my-notes.json
# Generate ENEX from JSON
enex-io to-enex backup.json
# Output: backup.enexOptions:
-o, --output <path> Specify output file path
-p, --pretty Pretty-print JSON output (default: true)
--version Show version number
--help Show helpAPI
import { parseEnex, generateEnex } from 'enex-io';
import fs from 'fs';
// 1. Parse ENEX → Note objects
const xml = fs.readFileSync('notes.enex', 'utf-8');
const notes = parseEnex(xml);
console.log(notes[0].title); // "My Note"
console.log(notes[0].created); // ISO 8601 string
console.log(notes[0].tags); // ['work', 'ideas']
// 2. Generate ENEX from Note objects
const myNotes = [
{
title: "Hello World",
content: "<div>This is a <b>test</b>.</div>",
tags: ["personal", "test"],
created: "2023-10-27T10:00:00.000Z",
updated: "2023-10-27T12:00:00.000Z"
}
];
const enex = generateEnex(myNotes, { application: 'MyApp' });
fs.writeFileSync('export.enex', enex);Type Definition
interface Note {
title: string;
content: string; // HTML content
tags: string[];
created: string; // ISO 8601
updated: string; // ISO 8601
author?: string;
sourceUrl?: string;
}
interface EnexOptions {
version?: string;
application?: string; // Appears in the <en-export> header
}License
MIT
{ github.com/mgks }
![]()
