draftjs_exporter
Library to convert rich text from Draft.js raw ContentState to HTML
What it is and what it does
draftjs_exporter is a Python library that translates Draft.js ContentState—the internal representation used by the Draft.js React editor—into HTML. Draft.js stores rich text in its own format rather than as HTML, so this exporter bridges that gap for Python backends, particularly in Wagtail/Django environments where you need to render Draft.js content server-side.
The library provides sensible defaults for common HTML elements (paragraphs, lists, emphasis, links) but is designed to be extended: you can define custom block and inline style maps, add decorators to transform line breaks, attach arbitrary attributes to elements, and create React-like custom components. It handles overlapping inline styles and nested lists automatically, converts entity data types (integers, booleans, style objects) to valid HTML attributes, and includes static type annotations throughout.
Use it for:
- Render Draft.js editor content to HTML on a Wagtail or Django backend without re-implementing the editor in Python.
- Export rich text from a Draft.js-based frontend editor to a database or file system as semantic HTML.
- Generate server-side HTML previews of Draft.js content before it is published or stored.
- Customize HTML output by mapping Draft.js blocks and styles to domain-specific HTML elements or CSS classes.
- Build a content pipeline where Draft.js ContentState is processed, validated, and converted to HTML in a Python service.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts Draft.js ContentState (a rich text editor format) to HTML, with configurable block and inline style mappings and support for nested lists and overlapping styles.
Yes. The package is actively maintained, has no security vulnerabilities, zero runtime dependencies, and a permissive MIT license. Install it if you need to convert Draft.js ContentState to HTML in a Python environment—particularly in Wagtail or Django projects. The low friction and stable API make it a straightforward choice for this specific use case.
Install
draftjs-exporter on PyPI
pip
pip install draftjs-exporteruv
uv add draftjs-exporterpoetry
poetry add draftjs-exporterInstalling draftjs_exporter
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained with a release 1 day old; supports Python 3.10 through 3.15 and passes mypy type checking.
License in practice
MIT license permits unrestricted use, modification, and distribution in commercial and private projects with minimal obligations.
Quickstart
pip install draftjs_exporter
from draftjs_exporter.html import HTML
config = {'entity_options': {}, 'composite_decorators': []}
exporter = HTML(config)
html_output = exporter.render(content_state)
Requires Python 3.10 or later; content_state must be a valid Draft.js ContentState object (typically a dict with 'blocks' and 'entityMap' keys).
Verify before relying
- Whether the package handles all Draft.js entity types and block types out of the box or requires custom configuration for non-standard content.
- Performance characteristics when processing large or deeply nested Draft.js documents.
- Whether custom component creation (mentioned in description) requires additional dependencies or setup beyond the base installation.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 1 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 999,142/month — #4,541 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: draftjs_exporter-7.1.0-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
mammothConverts Microsoft Word .docx documents to…
permissive · top 5,000 on PyPI
streamlit-quillEmbeds a React Quill rich-text editor component…
unclear · top 15,000 on PyPI
rich-rstRenders reStructuredText documents as Rich…
permissive · top 1,000 on PyPI
tinyhtmlRenders HTML5 safely from Python expressions…
permissive · top 15,000 on PyPI
quill-deltaImplements operational transformation for Quill…
permissive · top 15,000 on PyPI
django-quill-editorIntegrates Quill.js, a rich-text WYSIWYG…
permissive · top 15,000 on PyPI
prosemirrorProvides Python implementations of core…
permissive · top 15,000 on PyPI
gh-md-to-htmlConverts GitHub-flavored Markdown to HTML with…
unclear · top 15,000 on PyPI
python-editorProgrammatically open your system's $EDITOR…
permissive · top 5,000 on PyPI
markdown2Converts Markdown text to HTML using a fast,…
permissive · top 5,000 on PyPI