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
- Go to Notion Integrations
- Click "New integration"
- Give it a name (e.g., "marknotion")
- Select capabilities: Read, Update, Insert content
- 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
- Code blocks (with language)
- Blockquotes
- Horizontal rules
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file marknotion-0.2.9.tar.gz.
File metadata
- Download URL: marknotion-0.2.9.tar.gz
- Upload date:
- Size: 33.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
202615ee516085977e493918932cbe05c78933289239e41bb6fe964a0e3fe651
|
|
| MD5 |
7e6cece0274ca2892ff99c9bc26259c6
|
|
| BLAKE2b-256 |
b91dd7f8fb5de502cfc0ef42bd873fdd69a73017ace0a87aa9766b89a21ec097
|
Provenance
The following attestation bundles were made for marknotion-0.2.9.tar.gz:
Publisher:
workflow.yml on li3p/marknotion
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
marknotion-0.2.9.tar.gz -
Subject digest:
202615ee516085977e493918932cbe05c78933289239e41bb6fe964a0e3fe651 - Sigstore transparency entry: 1235237557
- Sigstore integration time:
-
Permalink:
li3p/marknotion@8d66db2dbd4aceee8bdd0080ef7840b445d9e775 -
Branch / Tag:
refs/tags/v0.2.9 - Owner: https://github.com/li3p
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@8d66db2dbd4aceee8bdd0080ef7840b445d9e775 -
Trigger Event:
push
-
Statement type:
File details
Details for the file marknotion-0.2.9-py3-none-any.whl.
File metadata
- Download URL: marknotion-0.2.9-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
769b3809ca50b81239d26a561c0e7ee58325cfcd4d6cb546186468e66154942e
|
|
| MD5 |
ee8bdf77853e0954b090275b1c1bcdd6
|
|
| BLAKE2b-256 |
893f1fbd09f628872f18cd1dba1b4e0937949a9075777c56fe0f945dccea201a
|
Provenance
The following attestation bundles were made for marknotion-0.2.9-py3-none-any.whl:
Publisher:
workflow.yml on li3p/marknotion
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
marknotion-0.2.9-py3-none-any.whl -
Subject digest:
769b3809ca50b81239d26a561c0e7ee58325cfcd4d6cb546186468e66154942e - Sigstore transparency entry: 1235237602
- Sigstore integration time:
-
Permalink:
li3p/marknotion@8d66db2dbd4aceee8bdd0080ef7840b445d9e775 -
Branch / Tag:
refs/tags/v0.2.9 - Owner: https://github.com/li3p
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@8d66db2dbd4aceee8bdd0080ef7840b445d9e775 -
Trigger Event:
push
-
Statement type: