Apple Notes only lives one place: Notes.app or the iCloud web client. There
is no export, API, or any easy way to read or edit your own notes from anywhere else.
icloud-md frees them from icloud by turning your Apple Notes into a folder
of real Markdown files, on Linux, Windows, or macOS, editable in whatever tool
you already use (Vim, VS Code, Obsidian, grep) and syncs your edits
back to iCloud as if you'd typed them into Notes.app all along.
# First, clone your notes somewhere
icloud-md clone ./my-notes
# Then make some changes to one of those notes
cd my-notes && $EDITOR "Grocery list.md"
# Finally, push them up to iCloud
icloud-md push
- Why
- Install
- Quick start
- Using Obsidian?
- Commands
- What works today
- Where the title lives
- Known limitations
- How it works
- Non-goals
- Comparison with other projects
- Reporting bugs
- Contributing / development
- License
Why
- Your notes become real files — one Markdown file per note, editable, versionable in git, greppable, diffable, scriptable — instead of locked inside Notes.app or the iCloud web client.
- Every OS, not just Apple's:
icloud-mdis a plain Node CLI. Clone your notes to Linux or Windows and treat them like any other folder of text, no Mac required. - Actually bidirectional, not just export:
pullandpushkeep your local folder and iCloud in sync in both directions — edit locally, edit in Notes.app, or edit from another device, and it reconciles. - Built-in version history: Every
pull/pushthat changes a note snapshots it, so you can inspect or roll back any past version of a note. - Conflict-awareness: If a note changed in iCloud
since your last sync and you edited it locally,
pulldoes a real three-way merge and only asks you to resolve the parts that actually overlap — the rest merges automatically. git-flavored CLI: You're probably already familiar with what the variousgitcommands do; that knowledge is most of what you need to know to use this tool.
Warning
This is not an official or supported Apple API. It works by reverse-engineering the private CloudKit web service that
www.icloud.com/notesitself talks to, and by reverse-engineering the format Notes uses to store note content. Apple can change either of those at any time without notice.Data loss is a real possibility, not a hypothetical one.
push,delete, andrevertall make real writes to your live Notes account based on this tool's own reverse-engineered understanding of Apple's formats, not documented behavior. This tool's own version-history snapshots (history/diff/revert) are a real safety net, but you should not assume they're infallible, and you should not treat this tool as a substitute for a real backup.Use this at your own risk, on your own account, and only against a working tree that's also a git repo (or otherwise backed up) so you always have an independent copy of your notes outside of iCloud and outside of this tool. Before relying on
push(ordelete, orrevert) against notes you care about, try it first against a disposable test note.A few things follow directly from the reverse-engineering:
- It likely requires Advanced Data Protection (ADP) to be disabled on the account — with ADP on, note content is end-to-end encrypted in a way this tool doesn't attempt to decrypt.
- Login itself is not reverse-engineered:
clone/reauthenticateopen a real, headed browser window and let Apple's own sign-in pages (password, 2FA, CAPTCHAs) run to completion, then harvest the resulting session. This keeps the tool out of the business of replicating Apple's login protocol, which changes far more often than the sync API does.
Install
Requires Node.js 20+.
npm install -g icloud-md
This puts the icloud-md command on your PATH.
Building from a clone of this repo instead:
git clone https://github.com/coddingtonbear/icloud-md.git
cd icloud-md
npm install
npm run build && npm link
(Re-run npm run build after pulling source changes.)
Quick start
icloud-md clone ./my-notes
The first run downloads a Chromium browser for sign-in automatically (a
one-off ~150 MB fetch), then opens it against www.icloud.com — sign in as
you normally would (password, 2FA, whatever your account requires). The
command detects sign-in completion on its own and closes the window;
closing it yourself aborts the clone. This walks your whole Notes zone
(including notes shared with you) and writes one Markdown file per note into
./my-notes, mirroring your Apple Notes folder structure — each note lands
in the same (sub)folder it's in inside Notes.app, with each sharer's notes
under a top-level directory named for them — and downloading any
attachments alongside their note.
If you keep your notes in Obsidian, read Using Obsidian?
before you clone — the vault shape is chosen once, at clone time.
After that:
cd my-notes
icloud-md status # what would `push` do right now?
icloud-md pull # fetch remote changes, merging with local edits
icloud-md push # send local changes back to iCloud
If you keep several vaults for the same Apple ID, name the account to skip
the sign-in window entirely — clone then reuses that account's saved
sign-in, and normally completes with no interaction at all:
icloud-md clone ./another-vault --account you@example.com
Without it, clone always asks: a new directory has no account yet, and
reusing a saved sign-in silently would let iCloud's own cookies decide
which account you got. Naming it removes the ambiguity — and if the completed
sign-in turns out to be a different Apple ID, the clone fails rather than
binding to the wrong one.
Later sign-ins for the same Apple ID typically skip 2FA — each account gets
its own persistent browser profile under
~/.config/icloud-md/accounts/<dsid>/, which Apple treats as a
trusted, returning browser. Credentials are never stored inside the vault
folder itself (a vault is exactly the kind of thing that gets copied,
zipped, or synced elsewhere); a cloned folder's own
.icloud-md/state.json only records which account it's bound to.
Signing in with a browser you already have
If the automatic Chromium download can't run on your machine (a locked-down VM, a proxy that blocks it) but a Chromium-based browser is already installed, point sign-in at it instead:
icloud-md --browser-executable /usr/bin/chromium clone ./my-notes
# or set it once, for every command:
export ICLOUD_MD_BROWSER_EXECUTABLE=/usr/bin/chromium
It must be the full path to the browser binary, and it is checked up front —
a path that doesn't exist or isn't executable fails the command before any
work starts. icloud-md still gives it its own sign-in profile rather than
touching your everyday one, and if it fails to launch you get that error,
including anything the browser printed on the way down — nothing is
downloaded behind your back.
Playwright is only tested against its own bundled build, so other versions
are best-effort. Without either setting, nothing changes: the bundled
browser is downloaded on first use, as above (or ahead of time with
icloud-md install-browser).
Using Obsidian?
Good news: I use this tool with Obsidian, too! There are two things you can do to make your experience of using this tool with Obsidian a little more polished:
-
Use the Apple Notes Sync plugin (source). It's a thin Obsidian front-end for this CLI: install
icloud-mdas above, install the plugin from the community plugin browser, and connect a folder. From there you pull and push from the ribbon, the command palette, or the status bar (and optionally on a schedule) without touching a terminal. Because it runs inside Obsidian, it can also perform the file renames a remote retitle calls for with link updating on, so your[[wikilinks]]follow the note instead of going stale (it uses--defer-renamesunder the hood). The plugin runs the initial clone for you when you click Connect; turn on its filename as title setting first if you want the vault shape described below, since that can't be changed afterwards. Desktop only. -
Not up for a plugin? Clone with
--filename-as-title.icloud-md clone ./my-vault --filename-as-titleEach file is then named for its note's title and holds only the body — the shape Obsidian expects — instead of repeating the title as the first line. Renaming a file retitles the note. Then run
icloud-md pull/icloud-md pushyourself whenever you want to sync; the one thing you lose versus the plugin is automatic wikilink updates when a note is retitled on another device (a plainpullrenames the file behind Obsidian's back). See Where the title lives for the full trade-offs.
Either way, Obsidian's own notation survives the round trip: wikilinks and
embeds, callouts, #tags, ==highlights==, and footnotes keep their
spelling on disk instead of collecting the backslashes plain Markdown would
want. YAML frontmatter is treated as local metadata — add aliases and tags
freely; they stay on your machine and never look like a note change.
Commands
| Command | What it does |
|---|---|
clone <directory> [--filename-as-title] [--account <appleId>] [--non-interactive] |
Full initial export into a fresh directory: every note, attachments included. Signs in via a browser window the first time a directory (or Apple ID) is used. Refuses to run against an already-cloned directory — use pull there instead. --filename-as-title picks the Obsidian-shaped layout for the vault; it can only be chosen here. --account clones as an Apple ID already signed in on this machine, reusing its saved sign-in instead of asking. --non-interactive never opens a sign-in window, failing instead — for unattended runs, where a window has nobody to complete it. |
pull [directory] [--defer-renames] |
Fetch everything that changed remotely since the last sync; auto-merges non-overlapping local edits, writes conflict markers for overlapping ones. Defaults to the current directory. --defer-renames is for editor integrations in a filename-as-title vault — see Where the title lives. |
push [directory] [--dry-run] |
Reconcile local disk state up to iCloud: creates notes for new .md files, uploads edited notes, moves notes whose file was deleted locally to Recently Deleted, and merges in remote changes to anything edited on both sides. Refuses anything ambiguous rather than guessing. |
status [directory] |
Preview exactly what the next push would do — creates, edits, deletes, and any refusals — without writing anything. Runs the same live checks push --dry-run does, so it needs to sign in. |
restore <file> [directory] |
Discard a tracked note's local, uncommitted edits, reverting the file to the last-synced copy. Purely local, no network call. |
delete <file> [directory] [--hard] |
Move a note to Recently Deleted (recoverable in Notes for ~30 days) and stop tracking it locally, keeping the locally-edited copy on disk as an untracked file. --hard permanently deletes instead — works even on attachment-bearing or unparseable notes, and on a note already soft-deleted. This is a real remote write with no confirmation prompt. |
history <file> [directory] [--records] |
List a note's version-history timeline, newest first. |
diff <file> <ref> [directory] |
Diff two history snapshots, or one snapshot against the current remote copy. <ref> is a snapshot/epoch id from history, or <from>..<to>. |
revert <file> <id> [directory] [--yes] |
Write a historical snapshot back to the server — the escape hatch if a note gets corrupted or a bad edit gets pushed. A real remote write; without --yes it only reports what it would do. |
object <list|show|delete> |
Record-level plumbing for repairing broken notes: list every raw CloudKit record in your Notes zone with health/reference info, inspect one record in full, or permanently delete one by ID. Run icloud-md object with no arguments for the full usage. |
reauthenticate [directory] |
Force a fresh sign-in for a directory's already-bound account. Useful if a session goes stale and silent recovery can't get back in on its own. Refuses if you sign into a different Apple ID than the one the directory was cloned for. |
verify-auth [directory] |
Check whether a directory's bound account session is still valid. |
bug-report --since <duration> [directory] |
Bundle version info, the last error, local sync state, and recent debug-log entries into a file to attach to a GitHub issue (e.g. --since 2h). --note <file> narrows it to one note; --no-state leaves the sync-state inventory out. |
install-browser |
Download the bundled sign-in browser now instead of on first sign-in — for setting up ahead of time, or retrying a download that failed. |
No commit/branch/merge equivalents exist — the working directory is
the local state, and the git repo you presumably wrapped around it (or the
history/diff/revert trio above) is where history and conflict
resolution live.
What works today
clone/pull/pushfor plain-text notes, including notes shared with you, with real three-way merging onpull.- Your Apple Notes folder structure is mirrored on disk
pullreconciles remote folder renames/moves by moving the note's file rather than the directory, andpushpicks up local moves between folders (a rename ormvof a tracked file) and sends the matching folder change upstream. A note you've moved but not pushed yet can still change on another device:pullfinds it at its new path by itsapple-note-idand merges the change in there, so the move still goes up on the nextpush. A directory the account doesn't have yet becomes a real Notes folder, nesting included —mkdir Recipes/Desserts, drop a note in, andpushcreates both folders ahead of the note. Notes shared with you live under a top-level directory per sharer, with their own shared folders nested underneath. All commands aregit-style about it — run them from anywhere inside the vault and file arguments resolve relative to your current directory. pushas a full reconciler: creating notes from new local files, uploading edits, moving notes between folders, and moving deleted-locally notes to Recently Deleted — all gated by an optimistic-lock check against the note's remote change tag, so a note that changed remotely since your last sync is reported as a conflict, never silently overwritten.- Rich-text formatting round-trips, not just plain text. Headings,
ordered/unordered/nested lists (including custom start numbers),
checklists, blockquotes, fenced monospace blocks, and inline
bold/italic/strikethrough/underline/links render to real Markdown on
pull/cloneand push back as the matching Apple formatting on edit. Anything this tool doesn't fully understand about a note's formatting stays read-only rather than risking a bad write. CR, CRLF and LF are treated as line breaks; Markdown uses LF, and pushing an edited note rewrites its line separators as LF while preserving paragraph boundaries. This applies inside note text; CRLF frontmatter remains unsupported. A fresh clone gets this representation immediately. An existing clone is refreshed when iCloud reports a change to that note; a pull with no remote note change leaves its tracked file alone. - Writing to notes shared with you is supported for creates and edits inside a shared folder you have write access to — not just the read side. See Known limitations for what's still refused.
- Attachments (images and audio confirmed): downloaded and rewritten
into note text as
attachments/-relative links (attachments live alongside the note in its own folder); re-downloaded only when the remote file's checksum actually changes. Anattachments/directory is reserved for them, so a note saved inside one is never pushed;statusandpushwarn about it. - Table edits. Cell edits, and inserting/deleting a contiguous run of rows or columns, round-trip both ways. Row/column reordering, and any edit that adds/removes rows and columns in the same save, are refused rather than risking a bad write — split a reorder into a delete push followed by an insert push instead.
- Obsidian notation survives the trip. Wikilinks and embeds
(
[[Note]],[[Note|alias]],![[img.png|300]]), callouts (> [!NOTE] Title), tags (#project), highlights (==like this==), and footnotes ([^1]) keep their notation in the local file instead of picking up the backslashes plain CommonMark would want (\[\[Note]],\#project). Text that would turn into different formatting if written bare — a#heading typed as text on a phone,[a](https://github.com/coddingtonbear/icloud-md/blob/HEAD/b),*stars*— still gets escaped, and every note is re-parsed before the friendlier spelling is kept, so it can never cost fidelity. Inside a table cell an alias pipe is written[[Note\|alias]], the form Obsidian itself requires there. - Markdown Apple Notes can't express is kept as text, not refused.
Inline code, images,
---rules,####–######headings, HTML blocks, footnote and link definitions, pipe tables that aren't one of the note's own tables, code or quotes nested in a list item, and fenced blocks with a language (```dataview,```itinerary) all push as their literal markdown — you'll see the raw syntax in Notes — and come back from the next pull as the same markdown. A push that couldn't come back that way is refused, so this can never leave a note read-only. A fence's language is the one case that used to be silently dropped (the block pushed as monospace and came back as a plain```); such a block now shows as plain text in Notes instead of monospace, which is the price of keeping its language. - Ordinary words keep their punctuation. Because GFM turns
www.…,https://…andname@hostinto links on sight, plain CommonMark escapes the punctuation that might start one — anywhere, in any word. That gave filesflow\.ts,window\.open(),me\@example.com, and (the case that prompted the fix)Www\.VJW\.digital.go.jp. Those are written as typed now, under the same re-parse check as everything above. - Local-only YAML frontmatter. A leading
---frontmatter block (for Obsidian tags, aliases, and the like) is treated as local metadata: it's skipped when deriving the note's title (the title is the first line after the