Skip to main content

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.

HOSTEDCONVERTYOURSFOREVERNotionpages · databasesblock treentnsyncblocks → markdownprops → frontmatter*.mdstable paths+ attachmentsgitone commitper syncnothing is ever written back — ntnsync only reads Notion

Why you would run this​

  1. 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.
  2. 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 log away — forever.
  3. 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 pull queues the pages that changed since the last run, ntnsync sync processes 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.
One-way, and read-only

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.

IN NOTIONON DISKPage“Engineering Wiki”tech/engineering-wiki.mdnotion_type: pageDatabase“Releases”releases/releases.mdnotion_type: databaseRow“client-platform v0.74.0”releases/client-platform-v0740.mdnotion_type: page + properties:Three different Notion concepts. One shape on disk: a markdown file.

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.

IN NOTIONON DISKPROPERTIESAutoproduncheckedComponentclient-platformIssues37baa28b…Last edited timeAug 17, 2026 11:42 AMproperties:Autoprod: falseComponent: "client-platform"Issues:- "37baa28b-3ffb-8176-9788-c4d8af067810"Last edited time: "2026-08-17T11:42:00.000Z"Property names are copied verbatim — spaces and casing included (Last edited time, never last_edited_time).List-shaped values 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​

  1. Get a Notion API Token

    Create an integration at https://www.notion.so/my-integrations and copy the token.

  2. Set the token

    export NOTION_TOKEN=secret_xxx
  3. Create root.md with your root pages

    cat > notion/root.md << 'EOF'
    # Root Pages

    - [x] **tech**: https://www.notion.so/Wiki-2c536f5e48f44234ad8d73a1a148e95d
    EOF
  4. Pull pages to queue (use --since for first pull)

    ntnsync pull --since 30d
  5. Sync the queue

    NTN_COMMIT=true ntnsync sync
  6. Pull updates later

    ntnsync pull
    NTN_COMMIT=true ntnsync sync

Environment Variables​

VariableRequiredDescription
NOTION_TOKENYesNotion integration token
NTN_DIRNoStorage directory (default: notion)
NTN_COMMITNoEnable automatic git commit
NTN_PUSHNoPush to remote after commits
NTN_GIT_URLNoRemote git repository URL
NTN_GIT_PASSNoGit password/token