Skip to main content

Convert basic HTML into DraftJS JSON format.

Project description


pip install html-to-draftjs


from html_to_draftjs import html_to_draftjs

json = html_to_draftjs("""
    <h1>My Page</h1>


    <p>Some <em>content</em> that is pretty <strong>interesting</strong></p>
    <p>Don't forget to <a href="">follow me!</a></p>

    <p><img src="" alt="image" /></p>


html_to_draftjs(raw_html_content: str[, features="lxml", strict=False]) -> dict

Converts a given HTML input into JSON.

  • features the features for the HTML tree-builder. By default it is set to lxml which is fast and powerful.
  • strict (boolean), if false, it will only warn on invalid operations. If true, it will raise errors.

soup_to_draftjs(bs_object: BeautifulSoup[, strict=False]) -> dict

Converts a given beautiful soup into JSON. Useful if you have to select a given part of the HTML content to convert it (e.g. #content).

  • strict (boolean), if false, it will only warn on invalid operations. If true, it will raise errors.

Supported Tags and Attributes


  • <div>, <p>
  • <h1> ... <h6>
  • <blockquote>
  • <li> and <ol> (doesn't support <ul> grouping)
  • Doesn't support the align attribute.

Inline Styling

  • <strong>, <b>
  • <em>, <i>


  • <img src="url" [alt="alt"] [height="123"] [width="123"]>
  • <a href="url">
  • <br/>
  • Doesn't support the title and align attributes.


./ develop
pip install -r requirements_dev.txt

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for html-to-draftjs, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size html-to-draftjs-1.0.1.tar.gz (6.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page