Skip to main content
Export your documents back to Notion. The tool creates Notion pages from your KB documents, preserving structure, formatting, and cross-references.
Prefer a UI? The same export is available as the in-app Notion integration — connect once in Settings > Integrations and Moxn runs the job for you. Both routes share the same converter; pick the CLI for scripted runs, CI, or fine-grained flag control.
If you have @moxn/context-cli installed, you can run context export-notion instead of npx @moxn/kb-migrate export-notion.

Prerequisites

  • Node.js 18+
  • A Notion integration token with write access to your workspace
  • A Notion parent page where exported pages will be created
  • A Moxn API key with read permissions (create one at Settings > API Keys in the web app)

Create a Notion Integration

If you don’t already have one from importing:
  1. Go to notion.so/my-integrations and click New integration
  2. Name it (e.g. “Moxn Exporter”), select your workspace, and click Submit
  3. Copy the Internal Integration Secret — this is your NOTION_TOKEN
  4. In Notion, open the parent page where you want exports to land
  5. Click the menu > Connections > Connect to and select your integration
The integration needs write access to the parent page. If you already have an integration from importing, you can reuse it.

Quick Start

Export all documents to Notion:
Preview what would be exported:
Export only a subtree:
You can set NOTION_TOKEN and MOXN_API_KEY as environment variables instead of passing them as flags.

How It Works

The export runs in two passes:

1. Fetch

The tool fetches documents from the Moxn API matching your filters (path prefix, date range).

2. Create Pages

Each document is created as a Notion page under your parent page. Sections become blocks: After all pages are created, the tool makes a second pass to convert internal KB document links into Notion page mentions, preserving cross-references.

4. Report

A summary shows what was created, skipped, or failed.

Conflict Strategy

When you re-run the export and pages already exist in Notion: --conflict-strategy=skip (default) — existing pages are left untouched:
--conflict-strategy=update — existing pages are updated with the latest content:
The tool matches existing pages by title. If you renamed a document in Moxn after a previous export, it will be created as a new page rather than updating the old one.

CLI Options

Examples

Export everything to Notion

Export a subtree

Update existing pages

Export recent changes

Dry run

Troubleshooting

Pass your token via --notion-token or set the environment variable:
You must specify the Notion page where exported content will be created. Get the page ID from the URL — it’s the 32-character hex string after the page title.
The Notion integration must have write access to the parent page. In Notion, open the parent page, click > Connections > Connect to and select your integration.
Internal links are resolved in a second pass after all pages are created. If the target document wasn’t included in the export (e.g., filtered out by --base-path), the link is left as plain text.
The Notion API has rate limits (~3 requests/second). For large workspaces, expect the export to take a few minutes. Use --base-path or date filters to export a smaller subset.

Next Steps

Import from Notion

Import Notion content back into Moxn

Export to Local Files

Download as markdown files instead