Skip to content

mgks/enex-io

Repository files navigation

enex-io

High-performance parser and generator for Evernote & Apple Notes (.enex) files.

npm version size npm downloads license

A lightweight, zero-dependency Node.js library and CLI tool to convert .enex files to JSON and back. Perfect for migrations, backups, and data processing.

Installation

# Install globally for CLI usage
npm install -g enex-io

# Install as a dependency in your project
npm install enex-io

Usage

CLI

Convert ENEX to JSON

enex-io to-json my-notes.enex
# Output: my-notes.json

Convert JSON to ENEX

enex-io to-enex backup.json
# Output: backup.enex

Options

-o, --output <path>   Specify output file path
-p, --pretty          Pretty print JSON output (default: true)
--version             Show version number
--help                Show help

API

Built for modern Node.js environments (ESM).

import { parseEnex, generateEnex } from 'enex-io';
import fs from 'fs';

// 1. Parse ENEX to Object
const xml = fs.readFileSync('notes.enex', 'utf-8');
const notes = parseEnex(xml);

console.log(notes[0].title); // "My Note"

// 2. Generate ENEX from Object
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 enexOutput = generateEnex(myNotes);
fs.writeFileSync('export.enex', enexOutput);

Type Definition

The standard Note object used by the parser and generator:

interface Note {
  title: string;
  content: string; // HTML content string
  tags: string[];
  created: string; // ISO 8601 Date String
  updated: string; // ISO 8601 Date String
  author?: string;
  sourceUrl?: string;
}

License

MIT

{ github.com/mgks }

Website Badge Sponsor Badge

About

High-performance parser and generator for Evernote/Apple Notes (.enex) files.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Contributors