---
name: evernote-data-handling
description: 'Best practices for handling Evernote data.

  Use when implementing data storage, processing notes,

  handling attachments, or ensuring data integrity.

  Trigger with phrases like "evernote data", "handle evernote notes",

  "evernote storage", "process evernote content".'
allowed-tools: Read, Write, Edit, Grep
version: 1.13.0
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>
tags:
  - saas
  - evernote
  - evernote-data
compatibility: Designed for Claude Code
title: evernote-data-handling
canonical_url: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/evernote-data-handling
last_updated: 2026-10-07T06:06:28.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/implementation-guide.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/evernote-data-handling/references/implementation-guide.md).
>
> If the user asked to install this Skill, run `npx skilld install jeremylongshore/tons-of-skills-marketplace/evernote-data-handling`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/evernote-data-handling`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jeremylongshore/tons-of-skills-marketplace/evernote-data-handling) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/evernote-data-handling`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/evernote-data-handling --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/evernote-data-handling --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Evernote Data Handling

## Overview

Best practices for handling Evernote data including ENML content processing, attachment management, local database sync, and ENEX export/import.

## Prerequisites

- Understanding of Evernote data model (Notes, Notebooks, Tags, Resources)
- Database for local storage (SQLite, PostgreSQL, etc.)
- File storage for attachments

## Instructions

### Step 1: Data Schema Design

Design a local database schema that mirrors Evernote's data model. Key tables: `notes` (guid, title, content, notebookGuid, created, updated, USN), `notebooks` (guid, name, stack), `tags` (guid, name), `resources` (guid, noteGuid, mime, hash, size). Track Update Sequence Numbers (USN) for incremental sync.

```sql
CREATE TABLE notes (
  guid TEXT PRIMARY KEY,
  title TEXT NOT NULL,
  content TEXT,
  notebook_guid TEXT REFERENCES notebooks(guid),
  created BIGINT,
  updated BIGINT,
  usn INTEGER DEFAULT 0
);
```

### Step 2: ENML Content Processing

Parse ENML to extract plain text (strip tags), convert to HTML (replace `<en-note>` with `<body>`, resolve `<en-media>` to `<img>`/`<a>` tags), or convert to Markdown. Validate ENML before sending to the API by checking for required declarations and forbidden elements.

```javascript
function enmlToPlainText(enml) {
  return enml
    .replace(/<\?xml[^>]*\?>/g, '')
    .replace(/<!DOCTYPE[^>]*>/g, '')
    .replace(/<[^>]+>/g, ' ')
    .replace(/\s+/g, ' ')
    .trim();
}
```

### Step 3: Resource (Attachment) Handling

Download resources via `noteStore.getResource(guid, withData, ...)`. Store binary data locally with the MD5 hash as filename. Track MIME types for proper content-type serving. Compute hashes for integrity verification.

### Step 4: Sync Data Manager

Implement incremental sync using `getSyncState()` to get the current server USN, then `getSyncChunk()` to fetch changes since your last sync. Process chunks in order: notebooks first, then tags, then notes, then resources.

```javascript
const syncState = await noteStore.getSyncState();
if (syncState.updateCount > lastSyncUSN) {
  const chunk = await noteStore.getSyncChunk(lastSyncUSN, 100, true);
  // Process chunk.notebooks, chunk.tags, chunk.notes, chunk.resources
}
```

### Step 5: Data Export

Export notes to ENEX (Evernote's XML export format), JSON, or Markdown. ENEX preserves the full note structure including resources and is compatible with Evernote import.

For the complete data schema, sync manager, ENML processor, and export implementations, see [Implementation Guide](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/evernote-data-handling/references/implementation-guide.md).

## Output

- SQL schema for local Evernote data storage
- ENML-to-text and ENML-to-HTML converters
- Resource download and local storage manager
- Incremental sync engine using USN tracking
- ENEX, JSON, and Markdown export utilities

## Error Handling

| Error | Cause | Solution |
|-------|-------|----------|
| `BAD_DATA_FORMAT` | Malformed ENML during update | Validate ENML with DTD check before API call |
| `QUOTA_REACHED` | Upload limit exceeded | Check `user.accounting.uploaded` before creating notes |
| `DATA_CONFLICT` | Note modified since last read | Refetch note by GUID and merge changes |
| Sync chunk gaps | Missed USN range | Request full sync from USN 0 |

## Resources

- Evernote Data Model
- [ENML Reference](https://dev.evernote.com/doc/articles/enml.php)
- [Synchronization](https://dev.evernote.com/doc/articles/synchronization.php)
- ENEX Export Format

## Next Steps

For enterprise features, see `evernote-enterprise-rbac`.

## Examples

**Local mirror**: Sync all notes to a local SQLite database using incremental sync. Store resources on disk keyed by MD5 hash. Use the local mirror for full-text search without API calls.

**Markdown export**: Convert all notes in a notebook to Markdown files, preserving folder structure from notebook stacks, and saving attachments to an `assets/` directory.
