
Research
/Security News
Bitwarden CLI Compromised in Ongoing Checkmarx Supply Chain Campaign
Bitwarden CLI 2026.4.0 was compromised in the Checkmarx supply chain campaign after attackers abused a GitHub Action in Bitwarden’s CI/CD pipeline.
draftjs-to-html
Advanced tools
A library for converting DraftJS Editor content to plain HTML.
This is draft to HTML library I wrote for one of my projects. I am open-sourcing it so that others can also be benefitted from my work.
npm install draftjs-to-html
import draftToHtml from 'draftjs-to-html';
const rawContentState = convertToRaw(editorState.getCurrentContent());
const markup = draftToHtml(contentState, directional, customEntityTransform);
Following is the list of conversions it supports:
| Block Type | HTML Tag | |
|---|---|---|
| 1 | header-one | h1 |
| 2 | header-two | h2 |
| 3 | header-three | h3 |
| 4 | header-four | h4 |
| 5 | header-five | h5 |
| 6 | header-six | h6 |
| 7 | unordered-list-item | ul |
| 8 | ordered-list-item | ol |
| 9 | blockquote | blockquote |
| 10 | unstyled | p |
It performs these additional changes to text of blocks:
- replace blank space in beginning and end of block with
- replace \n with <br>\n
- replace < with <
- replace > with >
Converts ordered and unordered list blocks with depths to nested structure of <ul>, <ol> and <li>.
Converts inline styles BOLD, ITALIC, UNDERLINE, STRIKETHROUGH, CODE, SUPERSCRIPT, SUBSCRIPT to corresponding HTML tags: <strong>, <em>, <ins>, <code>, <sup>, <sub>.
Converts inline styles color, background-color, font-size, font-family to a span tag with inline style details:
<span style="color:xyz;font-size:xx">. The inline styles should start with strings color or font-size like color-red, color-green or fontsize-12, fontsize-20.
Converts entity range of type link to anchor tag using entity data url for href: <a href="url" />.
Converts entity range of type mention to anchor tag using entity data url for href and also adds class to it: <a href="url" class="wysiwyg-mention" />.
Converts atomic entity image to image tag using entity data src for image source: <img src="src" />.
Converts embedded links to iFrames.
customEntityTransform can be used for transformation of a custom entity block to html.
Adding style property to block tag for block level styles like text-align: <p style="text-align: right">text</p>.
RTL, if directional function parameter is true, generated blocks have property dir = "auto" thus they get aligned according to bidi algorithm.
MIT.
The draft-js-export-html package provides similar functionality to draftjs-to-html by converting Draft.js ContentState to HTML. It offers more customization options for block and inline style rendering, making it a robust alternative.
The draft-convert package is another alternative that provides utilities for converting Draft.js ContentState to and from HTML. It offers a flexible API for defining custom block and inline style conversions, making it a versatile choice for developers.
FAQs
A library for draftjs to html conversion.
The npm package draftjs-to-html receives a total of 189,767 weekly downloads. As such, draftjs-to-html popularity was classified as popular.
We found that draftjs-to-html demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Bitwarden CLI 2026.4.0 was compromised in the Checkmarx supply chain campaign after attackers abused a GitHub Action in Bitwarden’s CI/CD pipeline.

Research
/Security News
Docker and Socket have uncovered malicious Checkmarx KICS images and suspicious code extension releases in a broader supply chain compromise.

Product
Stay on top of alert changes with filtered subscriptions, batched summaries, and notification routing built for triage.