--- id: draftjs-exporter version: "7.1.0" license: MIT license_treatment: permissive maintenance: active --- # draftjs_exporter — Library to convert rich text from Draft.js raw ContentState to HTML License: permissive · Maintenance: active · Downloads: 999.1K/mo ## 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 above — 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 pip install draftjs-exporter uv add draftjs-exporter poetry add draftjs-exporter ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 999.1K/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags draft.js to html converter, contentstate html export, rich text editor export, draft.js python library, convert draft.js output, html generation from draft.js, draft-js, wagtail-integration, html-generation [View on SkillFed](https://skillfed.io/packages/draftjs-exporter) · [View on PyPI](https://pypi.org/project/draftjs-exporter/)