Skip to main content

doc2mermaid

Convert documents to visual knowledge maps — powered by LLM + Mermaid.

Document Text → LLM Structure Extraction → Graph JSON → Mermaid → SVG/PNG

Install

pip install doc2mermaid

# Mermaid CLI for SVG/PNG rendering
npm install -g @mermaid-js/mermaid-cli

Quick Start

Python API

from doc2mermaid import doc_to_map

svg_path = doc_to_map(
    open("article.md").read(),
    output="map.svg",
    llm_base_url="https://api.openai.com/v1",
    llm_api_key="sk-...",
    llm_model="gpt-4o-mini",
)

CLI

export DOC2MERMAID_BASE_URL=https://api.openai.com/v1
export DOC2MERMAID_API_KEY=sk-...
export DOC2MERMAID_MODEL=gpt-4o-mini

doc2mermaid article.md -o map.svg
doc2mermaid article.md -o map.png --theme dark
cat article.txt | doc2mermaid - -o map.svg

How It Works

  1. Extract: LLM reads your document and extracts a graph structure (nodes + edges)
  2. Render: The graph is converted to Mermaid diagram syntax with auto-styling
  3. Output: Mermaid CLI renders the final SVG or PNG

Node Types & Colors

Type Color Use For
problem Red Problems, challenges, pain points
idea Purple Ideas, hypotheses, concepts
method Blue Methods, approaches, solutions
step Cyan Process steps, actions
result Green Results, outcomes, findings
takeaway Yellow Key takeaways, conclusions

Configuration

LLM settings via environment variables or function arguments:

Env Var Argument Description
DOC2MERMAID_BASE_URL llm_base_url OpenAI-compatible API base URL
DOC2MERMAID_API_KEY llm_api_key API key
DOC2MERMAID_MODEL llm_model Model identifier

Works with any OpenAI-compatible API (OpenAI, Claude, DeepSeek, local models, etc.).

License

MIT

Metadata

Release files for doc2mermaid 0.1.2

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

Built distribution (wheel)

Table of built distributions (wheels) for doc2mermaid 0.1.2
File Interpreter ABI Platform Actions
doc2mermaid-0.1.2-py3-none-any.whl Python 3 none any Details for doc2mermaid-0.1.2-py3-none-any.whl

Release files / doc2mermaid-0.1.2-py3-none-any.whl

Download URL doc2mermaid-0.1.2-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1539cc23061db1a4fb10b4c826476a1248b90902c0b1962e01165545a54dd46f
BLAKE2b-256 checksum
How to use checksums
3a4465660d530f897dac91cfcbc0018910e8bba0c566e6d38a9402d8e6feb608
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Security for doc2mermaid 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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