Converting HTML to Blocks JSON structure? Ideas?

System Information
  • Strapi Version: 4.19.0
  • Operating System: Linux
  • Database: MySql
  • Node Version: 20

Hi! We are currently using a HTML rich text plugin that stores HTML as a custom datatype in our Strapi content types.

Now with the introduction of the JSON based Blocks editor it would be interesting hor us to migrate from raw html to blocks. But rewriting all content by hand would be a very big task.

Has anyone looked into this? I could not find any recommendations in the docs. Or is there even already a script or tool?

Any feedback on how to perform a migration like this would be welcome.

My current though is to introduce the new field while keeping the old one (but deprecate it) and slowly migrate each entry one by one manually. Prioritizing the new field in rendering if it has content.

1 Like

I am currently not aware of preexisting script that does this, so I believe this is something you would have to create yourself.

The challenge would be parsing the preexisting html to json block supported content.

  • Blocks are full-width elements, usually at the root of the content. The available options are:
    • paragraph
    • heading (receives level)
    • list (receives format)
    • quote
    • code (receives plainText)
    • image (receives image)
    • link (receives url)
  • Modifiers are inline elements, used to change the appearance of fragments of text within a block. The available options are:
    • bold
    • italic
    • underline
    • strikethrough
    • code

I haven’t tried to do this yet, so not sure at level of complexity it would take.

You incremental strategy to update might be a better approach to get started with.

Hi!

Did you resolved this issue?