Notion import
The web import copies a Notion workspace into a new mddb workspace. The notion-import command writes the same content to a directory without a running server.
Import from the web app
Organization owners and admins can import. The import creates a new workspace named after the Notion workspace and makes you its admin.
Create a Notion integration
- Open Notion's new integration form.
- Name it, for example
mddb import, select the workspace to import, select the Internal type, and save. - In the Access tab, select Edit access and choose the pages to import.
- In the Configuration tab, clear Update content and Insert content. The import only reads.
- Next to Internal Integration Secret, select Show and copy the secret.
Start the import
- In mddb, select Import from Notion in the sidebar or the workspace menu.
- Paste the secret and select Start Import.
A banner shows progress. It reports the pages, databases, records, assets, and errors when the import ends. Cancel Import stops a running import. The import runs on the server, so you can keep working.
Notion content maps to mddb nodes
Pages become pages, and databases become tables. The import keeps the page hierarchy, nested blocks such as lists, toggles, and columns, icons, and covers. It downloads images, files, and videos next to the page that uses them.
| Notion property | mddb column | Value |
|---|---|---|
title | text | Plain text |
rich_text | markdown | Bold, italic, and links as Markdown |
number | number | Unchanged |
select, status | select | With options |
multi_select | multi_select | With options |
date, created_time, last_edited_time | date | Unix timestamp |
checkbox | checkbox | Unchanged |
url | url | Unchanged |
email | email | Unchanged |
phone_number | phone | Unchanged |
relation | relation | mddb IDs of the related records |
rollup | rollup | Value cached from Notion |
formula | formula | Value cached from Notion |
files | text | Paths of the downloaded files |
people, created_by, last_edited_by | text | Comma-separated names |
unique_id | text | PREFIX-123 format |
The Notion API does not expose database views. Imported tables have no saved views, so mddb shows them as plain tables. The command line can add views from a manifest.
Export with the command line
Install the command with Go:
go install github.com/maruel/mddb/backend/cmd/notion-import@latestPreview what the integration can read. The dry run prints JSON and writes nothing:
NOTION_TOKEN=ntn_your_secret notion-import -dry-runExport into <output>/<workspace>/:
NOTION_TOKEN=ntn_your_secret notion-import -workspace notion-export -output ./exportThe command writes files only. It does not create an mddb workspace, register members, or commit to Git. Use the web import to bring content into a running server.
| Flag | Default | Effect |
|---|---|---|
-token | NOTION_TOKEN | Notion integration secret. Required. |
-workspace | none | Name of the output directory. Required except with -dry-run. |
-output | ./data | Parent directory of the export. |
-database | all | Comma-separated database IDs to import. |
-page | all | Comma-separated page IDs to import. |
-views | none | View manifest YAML file. |
-include-content | true | Fetch page blocks. |
-max-depth | 0 | Maximum block nesting depth; 0 means unlimited. |
-dry-run | false | Show what would be imported, without writing. |
Exports rerun incrementally
The export writes notion_id_mapping.json beside the nodes. A second run into the same directory reuses its mddb IDs, so references between nodes stay valid. It rewrites nodes.jsonl and each table's data.jsonl.
Add views with a manifest
version: 1
databases:
- notion_id: "0123456789abcdef0123456789abcdef"
views:
- name: All tasks
type: table
default: true
sorts:
- property: Due
direction: asc
- name: By status
type: board
group_by: Status
filters:
- property: Status
operator: not_equals
value: Archivedversion must be 1. Each view needs a name and a type: table, list, gallery, board, or calendar. mddb does not render calendar views yet. Fields name properties by their column name.
| Field | Effect |
|---|---|
default | Opens this view first. |
columns | List of property, optional width, and optional visible. |
sorts | List of property and direction, asc or desc. |
filters | List of property, operator, and value; or nested and and or lists. |
group_by | Groups records by a property. |
hidden_groups | Group values to hide. |
Filter operators are equals, not_equals, contains, not_contains, starts_with, ends_with, gt, lt, gte, lte, is_empty, and is_not_empty.