export-notion
v0.1.2
Published
Export Notion pages to PDF with rendered Mermaid diagrams
Maintainers
Readme
export-notion
Export Notion pages to PDF with rendered Mermaid diagrams.
Solves the problem where Notion's built-in export doesn't render Mermaid diagrams.
Features
- Fetch page content via Notion API
- Render Mermaid diagrams as SVG/PNG images
- Export to PDF, HTML, or Markdown
- Multiple theme support (default, dark, forest, neutral)
- Custom CSS for PDF/HTML styling
Installation
# Run directly with npx (no install needed)
npx export-notion <page-id> ./output
# Or install globally
npm install -g export-notionNotion Integration Setup
- Go to https://www.notion.so/my-integrations
- Click "New integration"
- Enter a name and create
- Copy the "Internal Integration Token"
- Open the Notion page you want to export
- Click "..." (top right) -> "Connections" -> Add your integration
Usage
# Set token via environment variable
export NOTION_TOKEN="your-integration-token"
# Export to PDF (default)
npx export-notion <page-id-or-url> ./output
# Export to Markdown
npx export-notion <page-id-or-url> ./output -f md
# Export to HTML
npx export-notion <page-id-or-url> ./output -f html
# With options
npx export-notion <page-id-or-url> ./output -f pdf -t dark -i png -vOptions
| Option | Description | Default |
|--------|-------------|---------|
| -f, --format | Output format: pdf, md, html | pdf |
| -i, --image-format | Mermaid image format: svg, png | svg |
| -t, --theme | Theme: default, dark, forest, neutral | default |
| -v, --verbose | Verbose output | false |
| --token | Notion API token (alternative to env var) | - |
| --css | Custom CSS file for PDF/HTML styling | - |
Page ID Formats
You can specify the page in any of these formats:
# Page ID (32-character hex string)
npx export-notion abc123def456... ./output
# UUID format
npx export-notion abc123de-f456-... ./output
# Notion URL
npx export-notion "https://www.notion.so/My-Page-abc123def456..." ./outputOutput Structure
output/
└── My-Page/
├── My-Page.pdf
└── images/
├── mermaid-block1.svg
└── mermaid-block2.svgDevelopment
# Install dependencies
npm install
# Build
npm run build
# Run
node dist/cli.js <page-id> ./outputCustom CSS
You can customize the PDF/HTML output with your own CSS:
npx export-notion <page-id> ./output --css custom.cssExample custom.css:
body {
font-family: "Noto Sans JP", sans-serif;
line-height: 1.8;
max-width: 800px;
margin: 0 auto;
}
h1, h2, h3 {
color: #333;
}
code {
background: #f5f5f5;
padding: 2px 6px;
border-radius: 3px;
}License
ISC
