md2confluence
A Python tool to sync Markdown documentation to Confluence Cloud.
Features
- Markdown to Confluence conversion - Headers, lists, tables, code blocks, info panels, task lists, and more
- Front-matter support - Per-document settings via YAML/JSON front-matter
- Emoji shortcodes -
:smile:→ 😄,:rocket:→ 🚀 - Subscript/superscript -
H~2~O→ H₂O,x^2^→ x² - Page labels - Set Confluence labels via front-matter tags
- Image handling - Automatically uploads local images as attachments
- Local output mode - Generate Confluence Storage Format files without API calls
- Config-driven - Define document mappings in a simple config file
- Dry-run mode - Preview changes before syncing
- Retry logic - Exponential backoff for transient failures
- Rate limiting - Avoid API throttling
Installation
# From PyPI (recommended)
pip install md2confluence
# For development
git clone <repository-url>
cd md2confluence
pip install -e .
Dependencies
- Python 3.9+
requestslibrary (installed automatically)
Quick Start
-
Create an API token (see Authentication below)
-
Set environment variables:
export CONFLUENCE_API_TOKEN="your-api-token" export CONFLUENCE_USER_EMAIL="your-email@example.com"
-
Create a config file (
.confluence-sync.conf):CONFLUENCE_BASE_URL="https://your-domain.atlassian.net/wiki" CONFLUENCE_SPACE_KEY="DOCS" CONFLUENCE_TECH_PARENT_ID="123456789" # Document mappings: "Title|path/to/file.md|parent_page_id" CONFLUENCE_DOC_README="README|README.md|${CONFLUENCE_TECH_PARENT_ID}"
-
Run the sync:
md2confluence
Usage
# Sync all configured documents
md2confluence
# Dry-run (preview without changes)
md2confluence --dry-run
# List configured documents
md2confluence --list
# Verify config and connectivity
md2confluence --verify
# Sync a single document
md2confluence --single "Page Title" path/to/doc.md parent_page_id
# Convert markdown to Confluence format (stdout)
echo "# Hello" | md2confluence --stdin
# Local output (generate .csf files without API calls)
md2confluence --local ./output
Authentication
Creating an API Token
- Go to Atlassian API Tokens
- Click Create API token
- Enter a label (e.g., "md2confluence") and click Create
- Copy the token immediately (you won't see it again)
Required Permissions
The user account associated with the API token needs:
-
Space permissions:
- View space
- Add pages
- Update pages
- Add attachments
-
Page permissions:
- View, Edit on target pages/parent pages
For organization-managed accounts, ensure the user has appropriate Confluence access in your Atlassian admin settings.
Auth Modes
| Mode | Variables Required | Use Case |
|---|---|---|
| Basic | CONFLUENCE_USER_EMAIL + CONFLUENCE_API_TOKEN |
Standard Atlassian Cloud |
| Bearer | CONFLUENCE_API_TOKEN only |
OAuth tokens, service accounts |
Auth mode is auto-detected based on whether CONFLUENCE_USER_EMAIL is set.
Configuration
See confluence-sync.conf.example for all available options.
Document Mappings
Define documents to sync using CONFLUENCE_DOC_* variables:
CONFLUENCE_DOC_MYPAGE="Page Title|path/to/file.md|parent_page_id"
Edge Case Handling
| Option | Values | Default |
|---|---|---|
CONFLUENCE_MISSING_FILE_BEHAVIOR |
skip, fail | skip |
CONFLUENCE_IMAGE_FAILURE_BEHAVIOR |
placeholder, skip, fail | placeholder |
CONFLUENCE_TITLE_SPECIAL_CHARS |
sanitize, encode, fail | sanitize |
CONFLUENCE_EDITOR_VERSION |
v2 (modern), v1 (classic) | v2 |
Front-Matter
Documents can include YAML or JSON front-matter to override settings:
---
title: Custom Page Title
tags: [documentation, api, v2]
space: DOCS
parent_id: "123456789"
add_disclaimer: false
max_image_width: 600
synchronized: true
---
# Document content starts here
Supported Front-Matter Fields
| Field | Type | Description |
|---|---|---|
title |
string | Override page title |
tags / labels |
array | Confluence page labels |
space / space_key |
string | Target Confluence space |
parent_id / parent |
string | Parent page ID |
add_disclaimer |
boolean | Add auto-generated notice |
max_image_width |
integer | Image width constraint (px) |
image_failure_behavior |
string | Override error handling |
title_special_chars |
string | Override title sanitization |
synchronized / sync |
boolean | Set false to skip document |
Front-matter settings take precedence over config file and environment variables.
Markdown Support
- Headers (h1-h6)
- Bold, italic, strikethrough
- Subscript (
~text~) and superscript (^text^) - Ordered and unordered lists
- Nested lists
- Task lists (checkboxes)
- Tables
- Fenced code blocks with syntax highlighting
- Inline code
- Links (inline and reference-style)
- Images (uploaded as attachments)
- Blockquotes → Confluence panels (Note/Warning/Tip/Info)
- Horizontal rules
- Emoji shortcodes (
:smile:,:rocket:,:thumbsup:, etc.)
License
MIT
Metadata
Release files for md2confluence 1.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| md2confluence-1.1.5.tar.gz | 23.6 kB | Without provenance | Details for md2confluence-1.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| md2confluence-1.1.5-py3-none-any.whl | Python 3 | none | any | Details for md2confluence-1.1.5-py3-none-any.whl |
Total release size: 47.8 kB
Release files / md2confluence-1.1.5.tar.gz
| Download URL | md2confluence-1.1.5.tar.gz |
|---|---|
| Size | 23.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c39fffb379dd8133d48f5ca0ffcdd92708b742800a8f6372f524ea41a8abc802
|
|
BLAKE2b-256 checksum How to use checksums |
e6ed44f8019b33d763b42ef73fda2875806db6fdda4137ae169d7f4cda978e8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / md2confluence-1.1.5-py3-none-any.whl
| Download URL | md2confluence-1.1.5-py3-none-any.whl |
|---|---|
| Size | 24.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eca1ec29fb4dd07ff83daa668ac68c474edb00ccfaa3c88bdc2ccc61fb6f2ad0
|
|
BLAKE2b-256 checksum How to use checksums |
3fe322a67f750f1efcca109e40a05d656bb13f37d2c4ff248c5dca1dced9e9c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for md2confluence 1.1.5
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.