Skip to content

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 ​

  1. Open Notion's new integration form.
  2. Name it, for example mddb import, select the workspace to import, select the Internal type, and save.
  3. In the Access tab, select Edit access and choose the pages to import.
  4. In the Configuration tab, clear Update content and Insert content. The import only reads.
  5. Next to Internal Integration Secret, select Show and copy the secret.

Start the import ​

  1. In mddb, select Import from Notion in the sidebar or the workspace menu.
  2. 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 propertymddb columnValue
titletextPlain text
rich_textmarkdownBold, italic, and links as Markdown
numbernumberUnchanged
select, statusselectWith options
multi_selectmulti_selectWith options
date, created_time, last_edited_timedateUnix timestamp
checkboxcheckboxUnchanged
urlurlUnchanged
emailemailUnchanged
phone_numberphoneUnchanged
relationrelationmddb IDs of the related records
rolluprollupValue cached from Notion
formulaformulaValue cached from Notion
filestextPaths of the downloaded files
people, created_by, last_edited_bytextComma-separated names
unique_idtextPREFIX-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:

bash
go install github.com/maruel/mddb/backend/cmd/notion-import@latest

Preview what the integration can read. The dry run prints JSON and writes nothing:

bash
NOTION_TOKEN=ntn_your_secret notion-import -dry-run

Export into <output>/<workspace>/:

bash
NOTION_TOKEN=ntn_your_secret notion-import -workspace notion-export -output ./export

The 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.

FlagDefaultEffect
-tokenNOTION_TOKENNotion integration secret. Required.
-workspacenoneName of the output directory. Required except with -dry-run.
-output./dataParent directory of the export.
-databaseallComma-separated database IDs to import.
-pageallComma-separated page IDs to import.
-viewsnoneView manifest YAML file.
-include-contenttrueFetch page blocks.
-max-depth0Maximum block nesting depth; 0 means unlimited.
-dry-runfalseShow 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 ​

yaml
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: Archived

version 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.

FieldEffect
defaultOpens this view first.
columnsList of property, optional width, and optional visible.
sortsList of property and direction, asc or desc.
filtersList of property, operator, and value; or nested and and or lists.
group_byGroups records by a property.
hidden_groupsGroup 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.