Skip to main content

Bidirectional Markdown ↔ Notion blocks converter

Project description

marknotion

Bidirectional Markdown ↔ Notion converter with CLI tools.

Installation

# With uv (recommended for CLI tools)
uv tool install marknotion

# Or with pip
pip install marknotion

Setup

1. Create a Notion Integration

  1. Go to Notion Integrations
  2. Click "New integration"
  3. Give it a name (e.g., "marknotion")
  4. Select capabilities: Read, Update, Insert content
  5. Copy the "Internal Integration Token"

2. Set Environment Variable

export NOTION_TOKEN="secret_xxxxx..."

Or create a .env file in your project:

NOTION_TOKEN=secret_xxxxx...

3. Connect Pages to Your Integration

In Notion, open the page you want to access, click "..." menu → "Connections" → Add your integration.

CLI Commands

md2notion - Upload Markdown to Notion

# Update an existing page
md2notion README.md --page "https://notion.so/My-Page-abc123..."

# Create a new child page
md2notion guide.md --parent "abc123..." --title "User Guide"

notion2md - Export Notion to Markdown

# Print to stdout
notion2md "https://notion.so/My-Page-abc123..."

# Save to file
notion2md abc123... -o exported.md

notion-search - Search Notion Pages and Databases

# Search all (pages and databases)
notion-search "project"

# Search only databases (useful for finding database IDs)
notion-search "tracker" --type database

# Search only pages
notion-search "notes" --type page

# Limit results
notion-search project -n 5

Output includes type, ID, and clickable URL:

[Database] Projects
           ID:  1d73963f-ce05-8183-9af4-000b16a57189
           URL: https://www.notion.so/1d73963fce05813bac29eba023f0dd25

[Page]     Meeting Notes
           ID:  abc123de-f456-7890-1234-56789012abcd
           URL: https://www.notion.so/Meeting-Notes-abc123def4567890123456789012abcd

Python API

from marknotion import markdown_to_blocks, blocks_to_markdown, NotionClient

# Convert Markdown to Notion blocks
blocks = markdown_to_blocks("# Hello\n\nWorld")

# Convert Notion blocks to Markdown
md = blocks_to_markdown(blocks)

# Use NotionClient for API operations
client = NotionClient()  # Uses NOTION_TOKEN env var
client.update_page_content_from_markdown(page_id, markdown)

Supported Features

  • Headings (h1-h3)
  • Paragraphs
  • Bold, italic, strikethrough, inline code
  • Links
  • Bullet lists, numbered lists, nested lists, and task lists
  • Tables
  • Code blocks (with language normalization and long block splitting)
  • Blockquotes
  • Horizontal rules
  • Images
  • Math equations (inline and block)
  • Callouts/admonitions
  • Footnotes
  • YAML front matter

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marknotion-0.5.0.tar.gz (36.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marknotion-0.5.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file marknotion-0.5.0.tar.gz.

File metadata

  • Download URL: marknotion-0.5.0.tar.gz
  • Upload date:
  • Size: 36.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for marknotion-0.5.0.tar.gz
Algorithm Hash digest
SHA256 733d5718aa2aabf6030b7c78eeeb77af792292613fc2f00109035d04b48d1177
MD5 815335706aef41ad28125a8201be598a
BLAKE2b-256 d48396cd34c59aeaf9e3467c69a06f3a1a4de3ad7bf846087fb3010a502386b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for marknotion-0.5.0.tar.gz:

Publisher: workflow.yml on li3p/marknotion

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file marknotion-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: marknotion-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for marknotion-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 083b4d6068fa0bb6efe525bf4052f8110f75f53e26816bf11d2820b1791e049a
MD5 0fa3c766f0bfda4c3e5eb65268a2d0e5
BLAKE2b-256 4be927c4498f547b013aad92f4f534ac609370692777bb671f65836ef81d97b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for marknotion-0.5.0-py3-none-any.whl:

Publisher: workflow.yml on li3p/marknotion

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page