Skip to main content
Export your documents to local markdown files. The tool fetches documents via the API, converts sections to markdown, and downloads any attached images, PDFs, and CSVs.
If you have @moxn/context-cli installed, you can run context export-local instead of npx @moxn/kb-migrate export.

Prerequisites

  • Node.js 18+
  • A Moxn API key with read permissions (create one at Settings > API Keys in the web app)

Quick Start

Export all documents to a local directory:
Preview what would be exported without writing files:
Export only documents under a specific path:
You can also set MOXN_API_KEY as an environment variable instead of passing --api-key every time.

How It Works

The export runs in three steps:

1. Fetch

The tool calls the Moxn API to list all documents matching your filters (path prefix, date range). For each document, it fetches the full content including sections.

2. Convert

Each document’s sections are converted to markdown:

3. Write

Files are written to your output directory, mirroring the KB path structure.

Directory Structure

The exported files mirror your document hierarchy:
Asset directories (images/, pdfs/, csvs/) are created alongside the markdown files as needed. You can customize the directory names with --image-dir, --pdf-dir, and --csv-dir.

CLI Options

Examples

Export everything

Export a subtree

Export recent changes

Dry run

Troubleshooting

Pass your key via --api-key or set the environment variable:
Images stored in Moxn are downloaded automatically. External image URLs (e.g., https://...) are kept as URL references in the markdown. If downloads fail, the export continues and the image is replaced with a placeholder link.
The export writes files based on document paths. Existing files at the same path are overwritten. Files not matching any exported document are left untouched.
Large workspaces with many images or attachments take longer due to file downloads. Use --base-path to export a smaller subset, or --modified-after to export only recent changes.

Next Steps

Import Local Files

Import markdown back into Moxn after editing locally

Export to Notion

Push your docs to a Notion workspace instead