A Node.js tool to export Apple Notes to Markdown files with metadata preservation and folder structure mirroring.
- Preserves Folder Structure: Mirrors your Apple Notes folder hierarchy in the exported files
- HTML to Markdown Conversion: Uses Turndown to convert Apple Notes' HTML content to clean Markdown
- Metadata Preservation: Adds front matter with:
- Note title
- Folder path
- Creation date
- Modification date
- Apple Note ID
- Filename Sanitization: Removes special characters and ensures cross-platform compatibility
- Progress Indicators: Shows export progress with percentage completion and folder paths
- Duplicate Handling: Automatically appends numbers to duplicate filenames
- Error Handling: Gracefully handles notes that can't be accessed
- Search Filtering: Export only notes matching specific queries
-
Install the required dependency:
npm install turndown
Or install globally:
npm install -g turndown
-
Make the scripts executable (if not already):
chmod +x notes-export.js chmod +x notes-export-with-folders.js
Export all notes while preserving the Apple Notes folder hierarchy:
./notes-export-with-folders.jsSpecify a custom output directory:
./notes-export-with-folders.js -o ~/Documents/my-notesIf you prefer all notes in a single directory without folders:
./notes-export.jsExport only notes matching a search query:
./notes-export-with-folders.js -q "meeting" -o ./meeting-notesExport notes from a specific folder only:
# Export from a top-level folder
./notes-export-with-folders.js -f "Work" -o ./work-notes
# Export from a nested folder
./notes-export-with-folders.js -f "Personal/Journal" -o ./journal-export
# Combine folder and query filters
./notes-export-with-folders.js -f "Projects" -q "2024" -o ./2024-projectsExport a specific note by searching for its name:
# Search for notes containing "Meeting Notes"
./export-single-note.js "Meeting Notes"
# Export with exact name match
./export-single-note.js "Budget 2024" --exact
# Specify output directory
./export-single-note.js "Project Plan" -o ~/Desktop/
# Using npm script
npm run export-note "Meeting Notes" -- -o ./my-note-o, --output <dir>- Output directory (default:./notes-export)-q, --query <text>- Filter notes by search query-f, --folder <name>- Export only from specific folder-h, --help- Show help message
-o, --output <dir>- Output directory (default:./single-note-export)-e, --exact- Match exact note name (case-insensitive)-h, --help- Show help message
When using notes-export-with-folders.js, your exported notes will mirror the Apple Notes structure:
notes-export/
├── Personal/
│ ├── Journal/
│ │ ├── 2024_Reflections.md
│ │ └── Daily_Gratitude.md
│ └── Ideas/
│ └── App_Concepts.md
├── Work/
│ ├── Projects/
│ │ ├── Q1_Planning.md
│ │ └── Budget_2024.md
│ └── Meeting_Notes.md
└── Quick_Notes.md # Notes in root (no folder)
Each exported note includes front matter:
---
title: "Q1 Planning"
folder: "Work/Projects"
created: Tuesday, January 15, 2025 at 10:30:00 AM
modified: Wednesday, January 16, 2025 at 2:45:00 PM
apple_note_id: x-coredata://12345678-ABCD-1234-5678-123456789ABC/Note/p123
---
# Q1 Planning
## Objectives
- Launch new feature set
- Increase user engagement by 20%
- Hire 3 new engineers
...notes-export-with-folders.js- Exports notes while preserving Apple Notes folder structure (recommended)notes-export.js- Exports all notes to a single flat directoryexport-single-note.js- Export a single note by searching for its namenotes-cli.js- Base class for interacting with Apple Notes via AppleScript
Run npm install turndown in the script directory.
- Ensure you have write permissions for the output directory
- On macOS, you may need to grant Terminal/iTerm access to Apple Notes in System Preferences > Security & Privacy > Automation
- Check that Apple Notes is installed and has notes
- Try running without a query filter first
- Some system notes or locked notes may not be accessible
The exporter automatically sanitizes folder and file names to ensure compatibility across different operating systems. Special characters are replaced with safe alternatives.
These export scripts extend the NotesManager class from notes-cli.js and can be used alongside it:
notes-cli.js- Create, edit, search, and manage notes programmaticallynotes-export.js- Export notes to a flat directory structurenotes-export-with-folders.js- Export notes while preserving folder hierarchy
MIT