Skip to main content

Notion to Markdown (Python Version)

The original author of this work is Wei Xiang, please go to the original repository for more details.

I have only audited the code for usage within my company and made minor changes for compatibility with my code.


This is the Python implementation of nodejs version of notion-to-md, a tool that converts Notion pages into Markdown files.

Installation

Install the package via pip:

pip install notion-to-markdown

Usage

Sync Version

from notion_to_markdown import MarkdownProvider
from notion_client import Client

notion = Client(auth="your-auth-token")
n2m = MarkdownProvider(notion)
md_str = n2m.get_markdown_string("page-id")

with open("output.md", "w") as f:
    f.write(md_str)

Async Version

from notion_client import AsyncClient
from notion_to_markdown import MarkdownProvider

notion = AsyncClient(auth="your-auth-token")
n2m = MarkdownProvider(notion)
md_str = n2m.get_markdown_string_async("page-id")

with open("output.md", "w") as f:
    f.write(md_str)

Replace your-auth-token and page-id with the appropriate values from your Notion account.

Authentication with Notion API

  1. Create an integration in your Notion account and get the API key.
  2. Share your database with the integration to allow access.
  3. Retrieve your Database ID and Page ID from the Notion app.

Requirements

  • Python 3.7 or later
  • Notion API key

Limitations

  • The tool relies on the Notion API, and features are limited to what the API supports.
  • Embedding or downloading files other than images is not supported.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to improve the functionality or fix bugs.

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Submit a pull request with a clear description of your changes.

License

This project is licensed under the MIT License.

Metadata

Release files for notion-to-markdown 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for notion-to-markdown 0.1.6
File Size Uploaded
notion_to_markdown-0.1.6.tar.gz 16.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for notion-to-markdown 0.1.6
File Interpreter ABI Platform
notion_to_markdown-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 34.1 kB

Release files / notion_to_markdown-0.1.6.tar.gz

Download URL notion_to_markdown-0.1.6.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
84721b9a59e5baff0157672283b16cf16aebdce44cbfe52c7a3f445169f93a0c
BLAKE2b-256 checksum
How to use checksums
96ca52a8f8660a032b104ff6df7a67c1b556506b41b10f01bc90a132386165ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / notion_to_markdown-0.1.6-py3-none-any.whl

Download URL notion_to_markdown-0.1.6-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b69bdfced88831778f0f2cfd80c2f5d1ba4e6c82d46c4de69346c7566851f1d
BLAKE2b-256 checksum
How to use checksums
f472f5652f152f3985e704b15589d994373c6869a18e450371e8247e5a3ff377
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page