Skip to main content

Export a Confluence space to PDF/DOCX/Markdown/HTML with attachments, merging, and an interactive UI.

Project description

Confluence Exporter

Export an entire Confluence space to PDF, DOCX, Markdown or HTML โ€” with attachments embedded, optional consolidated volumes, and an interactive terminal UI.

PyPI Python License: MIT

Built for teams that need to archive, migrate, or feed their wiki into an LLM (NotebookLM, RAG pipelines, LLM fine-tuning). The tool produces clean, self-contained PDFs with embedded images and merged attachment appendices โ€” no missing links, no 0 KB files, no orphaned binary blobs.


Highlights

  • ๐Ÿ” Three auth strategies: API token (Basic), Personal Access Token (Bearer), or browser-cookie paste โ€” works on SSO-locked tenants where API tokens are disabled. Cookie parser is generic: paste the full Cookie: header from DevTools and any session-cookie name (cloud.session.token, tenant.session.token, โ€ฆ) works.
  • ๐Ÿ–จ๏ธ Pluggable PDF engines with automatic fallback: Playwright โ†’ WeasyPrint โ†’ xhtml2pdf. Pick one explicitly or let the tool auto-detect the best one you have installed.
  • ๐Ÿ“Ž Attachments really embedded: PDFs get merged as appendix pages into each document; images are inlined; others are listed with links.
  • ๐Ÿ“š Consolidated volumes: merge the per-page PDFs of a space into a few big PDFs with a generated Table of Contents and a hierarchical PDF bookmark outline โ€” upload-ready for NotebookLM.
  • ๐ŸชŸ Windows long-path safe: deep Confluence hierarchies that exceed MAX_PATH (260 chars) are handled via \\?\ prefixing and a _flat fallback bucket.
  • โšก Resumable: a per-space lockfile skips pages that haven't changed, so re-runs take seconds.
  • ๐ŸŽจ Nice terminal UI: colored prompts, progress bars, summary tables (powered by Rich + Typer).

Installation

pip install confluence-space-exporter

For best-quality PDFs (recommended), also install Playwright:

pip install "confluence-space-exporter[playwright]"
playwright install chromium

All engines in one shot:

pip install "confluence-space-exporter[all]"
playwright install chromium

Requires Python 3.10+.


Three ways to use it

The same codebase ships with three entry surfaces โ€” the business logic lives in the library; CLI and GUI are thin adapters on top.

Mode When to use it Launch
๐Ÿ–ฑ๏ธ Desktop app Prefer a window with forms, file pickers and a live log pane confluence-exporter-gui (alias: cfx-gui)
๐Ÿ’ป CLI / TUI SSH sessions, scripts, CI pipelines, or a rich terminal UI confluence-exporter (alias: cfx)
๐Ÿ“ฆ Library Embed the export inside your own Python code / data pipeline from confluence_exporter import SpaceExporter, โ€ฆ

Desktop app

confluence-exporter-gui

A Tkinter window with tabs for Connection โ†’ Export โ†’ Convert โ†’ Merge โ†’ Diagnose, a progress bar, and a live log pane. All long tasks run on a background thread so the UI stays responsive. No extra dependencies โ€” Tkinter ships with Python. (On some Linux distros you may need sudo apt install python3-tk.)

The status bar has a โน Stop button that cancels the current task gracefully โ€” the runner finishes the page it's on, saves the lockfile, and shuts down cleanly (no torn HTTP connections, no half-written PDFs). Run buttons disable while a task is running and re-enable when it finishes or cancels. Window geometry is remembered between sessions in ~/.confluence-exporter-gui.json.

The Connection tab shows a welcome banner while config is incomplete (it disappears once you've set base URL + space key + credentials), and the cookie textbox parses cookies live as you paste โ€” you'll see "โœ“ 12 cookie(s) parsed โ€” session token: cloud.session.token" before you even click Test connection.

CLI

# Interactive menu (recommended first run)
confluence-exporter

# Short alias
cfx

The tool walks you through auth setup, target space, and format, and saves your choices to config.json. Subsequent runs re-use it.

Non-interactive / scripted:

cfx export   --space MYKEY --format pdf --output ./out -y
cfx convert  ./out --engine playwright --merge -y
cfx merge    ./out_converted ./out_volumes --mode per_section -y

cfx diagnose        # check installed engines + credentials
cfx init-config     # edit / (re)create config.json

Press Ctrl+C during an export to cancel gracefully โ€” the current page finishes, the lockfile is saved, and the next run picks up where you left off.

Run cfx <command> --help for all options.

Library

from pathlib import Path
from confluence_exporter import (
    AppConfig, ConfluenceClient, SpaceExporter, OutputConverter, PDFMerger,
)

cfg = AppConfig()
cfg.confluence.base_url  = "https://your-tenant.atlassian.net"
cfg.confluence.space_key = "ABC"
cfg.confluence.auth_mode = "api_token"
cfg.confluence.email     = "you@example.com"
cfg.confluence.api_token = "โ€ฆ"

client = ConfluenceClient.from_config(cfg.confluence)
SpaceExporter(cfg, client).run()

OutputConverter(
    output_root=Path(cfg.export.output_path),
    target_format="pdf",
    engine="auto",
).run()

PDFMerger(
    source_root=Path(cfg.export.output_path + "_converted"),
    dest_root=Path("./volumes"),
    mode="per_section",
).run()

A full worked example โ€” including progress callbacks and all three auth modes โ€” is in examples/use_as_library.py.

Programmatic cancellation โ€” pass any threading.Event and set it from another thread (or a signal handler) to bail out gracefully:

import threading
cancel = threading.Event()

# Cancel after 30s if it isn't done by then
threading.Timer(30, cancel.set).start()

SpaceExporter(cfg, client, cancel_event=cancel).run()
# OutputConverter(..., cancel_event=cancel)
# PDFMerger(..., cancel_event=cancel)

Cancellation is cooperative: the runner checks the event between pages/files/groups and stops cleanly โ€” no torn HTTP requests, no half-written PDFs.


Three modes, end to end

1. Export โ€” download a Confluence space

cfx export

Writes pages + attachments to the output folder:

output/
โ””โ”€โ”€ MySpace/
    โ”œโ”€โ”€ Overview/
    โ”‚   โ”œโ”€โ”€ Introduction.html
    โ”‚   โ””โ”€โ”€ Architecture.html
    โ”œโ”€โ”€ attachments/
    โ”‚   โ”œโ”€โ”€ Introduction/
    โ”‚   โ”‚   โ””โ”€โ”€ diagram.png
    โ”‚   โ””โ”€โ”€ _flat/
    โ”‚       โ””โ”€โ”€ 12345_long-attachment-name.pdf
    โ””โ”€โ”€ _flat/                      # pages whose path was too long for Windows
        โ””โ”€โ”€ Nested_Deep_Page_9999.html

Incremental updates

Re-running export is safe and fast: it compares the live Confluence space against the per-space lockfile and only downloads what actually changed. Each page falls into one of four buckets:

State Meaning Action
NEW Page exists in Confluence, not in the lockfile Download
UPDATED Newer version on Confluence (or local file is missing) Re-download
UNCHANGED Same version, file still on disk Skip
DELETED-UPSTREAM In the lockfile but no longer in Confluence Optionally remove (cleanup_stale: true)

To preview what an export would do โ€” without downloading anything โ€” use the status command:

cfx status                     # summary only
cfx status --titles            # also list the actual page titles
cfx status --titles -n 50      # bump the per-bucket cap from 20 to 50

Sample output:

Diff
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Status                โ”ƒ #    โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ New                   โ”‚   3  โ”‚
โ”‚ Updated               โ”‚  12  โ”‚
โ”‚ Unchanged             โ”‚ 247  โ”‚
โ”‚ Deleted upstream      โ”‚   1  โ”‚
โ”‚ Total in Confluence   โ”‚ 262  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ†’ Running export would download 3 new + 12 updated page(s).

The GUI exposes the same thing as a "๐Ÿ” Check status" button on the Export tab.

Tip: if you delete a PDF on disk, the next run notices and re-downloads it (the lockfile alone isn't trusted โ€” we also check the file is actually there).

2. Convert โ€” HTML โ†’ PDF / DOCX with embedded attachments

cfx convert ./output

Produces ./output_converted/ mirroring the source tree. Each PDF has its page's PDF attachments merged as appendix pages. The conversion tolerates deep Windows paths (renders via %TEMP% and moves into place) and validates every output via magic-byte + size checks โ€” no 0 KB files slip through.

3. Merge โ€” consolidated volumes for NotebookLM / archival

cfx merge ./output_converted ./output_volumes

Three grouping modes:

Mode Output Best for
per_section One PDF per top-level folder of each space NotebookLM sources (smaller, focused)
per_space One PDF per Confluence space Sharing a whole space as a single file
single One PDF for everything Archival / grep-friendly single file

Each volume contains a generated Table of Contents page (page numbers + nesting) and a PDF outline that every reader (Acrobat, Edge, Chrome, Foxitโ€ฆ) shows as a navigation sidebar.


Authentication

Option 1 โ€” Atlassian API token (easiest, if your admin allows it)

"auth_mode": "api_token",
"email": "you@company.com",
"api_token": "ATATT3xโ€ฆ"

Get a token at https://id.atlassian.com/manage-profile/security/api-tokens.

Option 2 โ€” Browser cookie (for SSO-only tenants)

"auth_mode": "browser_cookie",
"cookies": {
  "cloud.session.token": "eyJโ€ฆ",
  "atlassian.xsrf.token": "โ€ฆ"
}

Easiest way to set this up:

cfx init-config   # or choose menu option 5

The tool walks you through copying the full Cookie: header from DevTools โ€” it then parses and forwards every cookie the browser would send, so it doesn't matter whether your tenant uses cloud.session.token, tenant.session.token, JSESSIONID or something else.

Option 3 โ€” Personal Access Token (Server / Data Center)

"auth_mode": "pat",
"personal_access_token": "NjAxMโ€ฆ"

Sent as Authorization: Bearer โ€ฆ.


Configuration

A full config.json looks like examples/config.example.json. All fields have sane defaults and are overridable via CLI flags.

Keys starting with _ are treated as inline documentation and ignored at load time.


Standalone executable (no Python required for end users)

If you want to ship a double-clickable .exe / .app for users who don't have Python installed, bundle it with PyInstaller:

pip install "confluence-space-exporter[all]" pyinstaller
# Windows / macOS / Linux (run on the target OS):
pyinstaller --name ConfluenceExporter --windowed --onefile ^
  --collect-all confluence_exporter ^
  -m confluence_exporter.gui

The resulting dist/ConfluenceExporter.exe (or .app on macOS) embeds Python and all dependencies. For the Playwright engine specifically, Chromium binaries are large and best installed separately after first launch โ€” in a bundled build, prefer weasyprint or xhtml2pdf out of the box.


Troubleshooting

Symptom Likely cause / fix
HTTP 401 Unauthorized API token disabled by admin โ†’ switch to browser_cookie mode.
HTTP 403 Forbidden when exporting PDFs Confluence's native PDF endpoint is disabled; the tool will fall through to local rendering automatically.
Playwright Chromium binary not installed python -m playwright install chromium.
[Errno 2] No such file or directory (Windows) Path exceeds MAX_PATH. The tool falls back to _flat/ automatically โ€” enable it in your run.
0 KB PDFs The older engine couldn't render a page. Install Playwright and rerun: cfx convert --engine playwright.

Run cfx diagnose any time to see what's installed and confirm your credentials.


Contributing

See CONTRIBUTING.md. PRs welcome!


License

MIT โ€” see LICENSE.

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

confluence_space_exporter-0.1.0.tar.gz (59.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

confluence_space_exporter-0.1.0-py3-none-any.whl (60.6 kB view details)

Uploaded Python 3

File details

Details for the file confluence_space_exporter-0.1.0.tar.gz.

File metadata

File hashes

Hashes for confluence_space_exporter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3465489919ea73331f3bfa00c0d5e5585c9f5c63bf3c0547187c1b7caa1aa09e
MD5 4dd968ba5dc089fbe71633407b34f24c
BLAKE2b-256 5f8f49b4ceb221ba9f3affae056ba16b282928c5f591567146ce6c2651e8f919

See more details on using hashes here.

Provenance

The following attestation bundles were made for confluence_space_exporter-0.1.0.tar.gz:

Publisher: publish.yml on LeoChi/confluence-exporter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file confluence_space_exporter-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for confluence_space_exporter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 979878057a938bc07591636e30e1c0a85040c45e9601facf5c3e6716f39c63c3
MD5 90bb34853be46e7a307ea4dead5296f3
BLAKE2b-256 6b70064ff063049b0aef6205fbbf8605b85aead811ce52cfd2dc16d1add2c600

See more details on using hashes here.

Provenance

The following attestation bundles were made for confluence_space_exporter-0.1.0-py3-none-any.whl:

Publisher: publish.yml on LeoChi/confluence-exporter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page