Convert documents to Markdown using Cloudflare Workers AI toMarkdown.
Project description
anything2md
Python package and CLI for converting URLs or local documents into Markdown using Cloudflare Workers AI toMarkdown().
Install
From PyPI with uv:
uv add anything2md
Or from PyPI (pip):
pip install anything2md
Cloudflare Token Setup
Create a Cloudflare API Token for the target account and include these permissions:
Workers AI-- ReadBrowser Rendering-- Edit
Usage
import anything2md
mdconverter = anything2md(account_id="xxx", api_token="xxx")
result = mdconverter.transform("https://example.com")
result = mdconverter.transform("https://pub-979cb28270cc461d94bc8a169d8f389d.r2.dev/somatosensory.pdf")
result = mdconverter.transform("https://pub-979cb28270cc461d94bc8a169d8f389d.r2.dev/cat.jpeg")
print(result.markdown)
Supported Formats
Based on Cloudflare docs, current supported extensions include:
pdf, jpeg/jpg, png, webp, svg, html/htm, xml, csv, docx, xlsx, xlsm, xlsb, xls, et, ods, odt, numbers
url via Browser Rendering Markdown endpoint.
Local Usage
Install dependencies:
uv sync
export CLOUDFLARE_ACCOUNT_ID="your_account_id"
export CLOUDFLARE_API_TOKEN="your_api_token"
uv run anything2md https://pub-979cb28270cc461d94bc8a169d8f389d.r2.dev/somatosensory.pdf
uv run anything2md https://pub-979cb28270cc461d94bc8a169d8f389d.r2.dev/cat.jpeg -o output.md
uv run anything2md https://example.com
Integration Test (Real Cloudflare)
If both CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN are set, integration tests automatically run real Cloudflare calls and validate that:
result.erroris emptyresult.markdownis non-empty
Optional test URL overrides:
ANYTHING2MD_TEST_PDF_URLANYTHING2MD_TEST_IMAGE_URLANYTHING2MD_TEST_WEB_URL
References
Cloudflare docs:
- Markdown Conversion overview: https://developers.cloudflare.com/workers-ai/features/markdown-conversion/
- API reference (
toMarkdown): https://developers.cloudflare.com/api/resources/ai/methods/run/#to-markdown-conversion-to-markdown - API reference (
supported formats): https://developers.cloudflare.com/api/resources/ai/methods/run/#to-markdown-conversion-supported-formats - Browser Rendering Markdown endpoint (URL input): https://developers.cloudflare.com/browser-rendering/rest-api/markdown-endpoint/
- Markdown for Agents (
Accept: text/markdown): https://developers.cloudflare.com/fundamentals/reference/markdown-for-agents/
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
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 anything2md-0.1.2.tar.gz.
File metadata
- Download URL: anything2md-0.1.2.tar.gz
- Upload date:
- Size: 22.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
483d758c1f0e79dad90ef3bfe7264d3c5c3ca23222a78d0b123a47688ceb6502
|
|
| MD5 |
1528f621777279281d319bf7e0d254ee
|
|
| BLAKE2b-256 |
96299002b1a96f2cef78dcfac1becabeb618394cddd10126a464f43d9f0c3e50
|
Provenance
The following attestation bundles were made for anything2md-0.1.2.tar.gz:
Publisher:
publish.yml on herrkaefer/anything2md
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anything2md-0.1.2.tar.gz -
Subject digest:
483d758c1f0e79dad90ef3bfe7264d3c5c3ca23222a78d0b123a47688ceb6502 - Sigstore transparency entry: 1004090308
- Sigstore integration time:
-
Permalink:
herrkaefer/anything2md@98e3eb3912f526c9b90977c9ffa13fe4d61f637e -
Branch / Tag:
refs/heads/master - Owner: https://github.com/herrkaefer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@98e3eb3912f526c9b90977c9ffa13fe4d61f637e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file anything2md-0.1.2-py3-none-any.whl.
File metadata
- Download URL: anything2md-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.6 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 |
607cd6c6674c5591077d297ef14a1f5491a6f0e287d1d8ef5ea17c1999ce503b
|
|
| MD5 |
146b9ad6ec56ca275ed4626d9e96223e
|
|
| BLAKE2b-256 |
12541603b3f8608445af98d361eb340c4dd2e08a4b2f9c068f16aa82991e4552
|
Provenance
The following attestation bundles were made for anything2md-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on herrkaefer/anything2md
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anything2md-0.1.2-py3-none-any.whl -
Subject digest:
607cd6c6674c5591077d297ef14a1f5491a6f0e287d1d8ef5ea17c1999ce503b - Sigstore transparency entry: 1004090310
- Sigstore integration time:
-
Permalink:
herrkaefer/anything2md@98e3eb3912f526c9b90977c9ffa13fe4d61f637e -
Branch / Tag:
refs/heads/master - Owner: https://github.com/herrkaefer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@98e3eb3912f526c9b90977c9ffa13fe4d61f637e -
Trigger Event:
workflow_dispatch
-
Statement type: