Export Apple Notes to HTML and Markdown on macOS, using Shortcuts.app
and a bite of Python
See also Apple Reminders Exporter
- Clone repository (Terminal)
git clone https://github.com/Kylmakalle/apple-notes-exporter
cd apple-notes-exporter
- Install
Export Notes
Shortcut using Link oropen "Export Notes.shortcut"
file Shortucts.app
> Settings > Advanced > Allow Sharing Large Amounts of Data- Run
make
Shortcuts.app
will ask for your approval to save notes and images. Click Allow.- If you miss-clicked or something does not work, Go to
Export Notes
Shortcut > (i) Shotcut details > Privacy > Reset Privacy and Try again.
- Done! You can find files at notes directory
- Only Image attachements are supported. Drawings do not export for some reason.
- Protected notes are not supported. They will only have a title. For some reason,
Shortcuts.app
generates new empty image with the title of a protected note on each launch. Considermake clean
to delete all notes and export them again. - Markdown exports via Make Markdown from Rich Text Shortcut action "comparable to Aaron Swartz's html2text script" as Apple says. Looks like it's done with textutil. The converter doesn't work well with headings, tables and much more, that's why HTML sources are also present. Source RTF will lack of any attachment references for some reason.
Not sure why Apple decided to set html2text as their quality bar. Perhaps, there're much more modern converters.
- Notes with long titles may exceed file path limit.
Probably, you're here because you don't want to lose your data due to various reasons. Me too. I don't trust .shortcuts
format much, that's why you can find visual source of Export Notes.shortcut
in shortcut-source.
While Implementing this shortcut, I've tried various actions, below I'll share some of the insights I got that might me helpful to any Shortcut creator.
Export Notes.shortcut
creates files in format$creation_date^$escaped_folder_name^$escaped_note_name[^$attachment_name]
and then I use Python to re-create folder structure. The need for post-processign is simple, otherwiseShortcuts.app
will ask your Write approval for each created folder (even if it was created within the shortcut). That means you'll need to click Allow for each note you have. This may be hundreeds or thousands.Creation date is required to distingush different notes with the same title.
Shortcuts.app
does file changes in a temporary directory~/Library/Group Containers/group.is.workflow.shortcuts/Temporary/com.apple.WorkflowKit.BackgroundShortcutRunner
. For some reason,Rename
orMove
File actions caused errors likecouldn't be moved to "com.apple.WorkflowKit.BackgroundShortcutRunner" because an item with the same name already exists.
. Instead,- When providing Subpath to
Save File
action, only top-level Subpath will work. e.g. "SaveHTML
toPATH
, Subpath:notes/backup/latest
" will not work. Justnotes
will. - Apple exports Note's HTMLs with
file:///
references to attachements. This doesn't work for both HTML and Markdown previews for some reason. Simple python script replaces these occurances to source local directory.
While I think exporting via Shortcuts.app
is more or-less official and should less likely to break in the future, here's what I've found:
- Exporter macOS app with similar to
Shortcuts.app
capabilities - Automate Copy-Pasting
- Access internal Database