Introduction
ntnsync mirrors a Notion workspace into plain markdown files in a git repository, continuously.
Every page — and every database, and every row of every database — becomes one .md
file whose path never changes, committed on every sync.
Why you would run this
- Your LLM can actually read it. The Notion API makes an agent paginate a block tree, one page at a time. A markdown tree is grep-able and chunk-able, so the whole workspace fits into a coding agent's context the same way your source code does.
- History with no expiry date. Notion's page history is capped by your plan. Git's is not
capped at all. Every sync is a commit, so "what did this spec say in March?" is a
git logaway — forever. - No lock-in, no cliff edge. If the subscription lapses or the team moves tools, nothing has to be rescued. The knowledge is already on disk, in the one format every editor, search tool and model already reads.
"But Notion already exports markdown"
It does — once, by hand, into a fresh folder with fresh filenames. ntnsync differs in three ways, and they are the whole point:
- It runs continuously.
ntnsync pullqueues the pages that changed since the last run,ntnsync syncprocesses the queue. Put it on a schedule or wire it to a Notion webhook and the mirror keeps itself current. - File paths are stable. Renaming a page in Notion does not move its file. A rename shows up as a one-line change to the title, not as a delete plus an add somewhere else in the tree.
- Every version lands in git. Because the paths hold still, the diffs actually mean something:
you can follow a single document through its whole life with
git log --follow.
ntnsync reads Notion and writes files. It never writes back to Notion — not a page, not a property, not a comment. Editing the generated markdown changes nothing in your workspace, and the next sync will overwrite it.
So this is a mirror, not a backup you can restore into. What you get is readable, searchable, permanently versioned markdown — not a workspace in a box.
Everything is a page
Notion has several concepts that behave differently in its UI: a page, a database, and a row
inside a database. ntnsync flattens all three into the same thing on disk — a markdown file
with frontmatter. The notion_type field records which one it came from.
A database file lists its rows; each row is its own file next to it. Nothing needs a special reader — it is markdown all the way down.
Properties become frontmatter
A database row carries properties. ntnsync copies them into YAML frontmatter under a properties:
key, verbatim: the property name you see in Notion is the key you get in the file, spaces and
capitalisation included. List-shaped values (relations, multi-selects, people) nest as a YAML
sequence under their own key; everything else stays flat.
Verbatim names are a deliberate trade: the file reads like the Notion page rather than like a normalised export, so a human (or a model) reading the file recognises the workspace it came from.
Stable file paths
This is the feature the rest depends on. A file is named once, from the page's identity, and keeps that name for good:
- Rename a page in Notion and the file stays where it is.
- Move a page and its file stays where it is.
- Diffs therefore describe content changes, not filesystem churn.
Stable paths are what make the git history usable, and a usable history is what lets a model (or you) follow a document through time.
Installation
From Source
go install github.com/fclairamb/ntnsync@latest
Docker
docker pull ghcr.io/fclairamb/ntnsync:latest
Quick Start
-
Get a Notion API Token
Create an integration at https://www.notion.so/my-integrations and copy the token.
-
Set the token
export NOTION_TOKEN=secret_xxx -
Create root.md with your root pages
cat > notion/root.md << 'EOF'# Root Pages- [x] **tech**: https://www.notion.so/Wiki-2c536f5e48f44234ad8d73a1a148e95dEOF -
Pull pages to queue (use --since for first pull)
ntnsync pull --since 30d -
Sync the queue
NTN_COMMIT=true ntnsync sync -
Pull updates later
ntnsync pullNTN_COMMIT=true ntnsync sync
Environment Variables
| Variable | Required | Description |
|---|---|---|
NOTION_TOKEN | Yes | Notion integration token |
NTN_DIR | No | Storage directory (default: notion) |
NTN_COMMIT | No | Enable automatic git commit |
NTN_PUSH | No | Push to remote after commits |
NTN_GIT_URL | No | Remote git repository URL |
NTN_GIT_PASS | No | Git password/token |