{"id":15459209,"url":"https://github.com/sodoteo/contentful-html-to-richtext","last_synced_at":"2026-05-02T09:31:48.215Z","repository":{"id":65140194,"uuid":"583106639","full_name":"SodoTeo/contentful-html-to-richtext","owner":"SodoTeo","description":"Tool that converts HTML to the rich-text format used by Contentful. Useful for migrating content or integrating with the Contentful platform.","archived":false,"fork":false,"pushed_at":"2023-01-25T14:05:41.000Z","size":159,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-25T12:49:46.222Z","etag":null,"topics":["contentful","html","html5","migration-tool","module","parser","rich-text","richtext"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SodoTeo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-28T19:35:47.000Z","updated_at":"2024-04-06T13:46:54.000Z","dependencies_parsed_at":"2023-02-14T08:00:58.478Z","dependency_job_id":null,"html_url":"https://github.com/SodoTeo/contentful-html-to-richtext","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SodoTeo%2Fcontentful-html-to-richtext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SodoTeo%2Fcontentful-html-to-richtext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SodoTeo%2Fcontentful-html-to-richtext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SodoTeo%2Fcontentful-html-to-richtext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SodoTeo","download_url":"https://codeload.github.com/SodoTeo/contentful-html-to-richtext/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246009749,"owners_count":20709012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["contentful","html","html5","migration-tool","module","parser","rich-text","richtext"],"created_at":"2024-10-01T23:05:26.898Z","updated_at":"2026-05-02T09:31:48.189Z","avatar_url":"https://github.com/SodoTeo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# contentful-html-to-richtext\n![npm type definitions](https://img.shields.io/npm/types/html-to-richtext-contentful)\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/SodoTeo/contentful-html-to-richtext?color=success)\n![GitHub](https://img.shields.io/github/license/SodoTeo/contentful-html-to-richtext)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/e80bd35b11d848c7a427c4efe6d923fc)](https://www.codacy.com/gh/SodoTeo/contentful-html-to-richtext/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=SodoTeo/contentful-html-to-richtext\u0026amp;utm_campaign=Badge_Grade)\n\n\nModule that converts HTML to the [Contentful](https://www.contentful.com/) rich-text model. \nIt was developed to assist in the process of migrating rich text content into contentful, a popular content management system. \nThe functionality has been thoroughly tested to ensure that it performs reliably. It is a useful tool for anyone who\nneeds to convert HTML to contentful's rich-text format, whether for the purpose of migrating existing content or integrating with contentful's platform.\n\n**This module is under development**\n\n## Current Status\n\n| Verified      | Verified           | Beta           |\n| ------------- |:------------------:|:--------------:|\n| `\u003cul\u003e`        | `\u003cembedded-asset\u003e` | `\u003cimg\u003e`        |\n| `\u003cli\u003e`        | `\u003cinline-entry\u003e`   | `\u003casset-hyperlink\u003e`|\n| `\u003col\u003e`        | `\u003cembedded-entry\u003e` |                |\n| `\u003cb\u003e`         | `\u003centry-hyperlink\u003e`|                |\n| `\u003cu\u003e`         | `\u003ctd\u003e`             |                |\n| `\u003ci\u003e`         | `\u003cth\u003e`             |                |\n| `\u003cp\u003e`         | `\u003ctr\u003e`             |                |\n| `\u003cbr /\u003e`      | `\u003ctable\u003e`          |                |\n| `\u003ccode\u003e`      | `\u003cp\u003e`              |                |\n| `\u003ca\u003e`         | `\u003chr\u003e`             |                |\n| `\u003cblockquote\u003e`| `\u003ch{1-6}\u003e`         |                |\n\n## Installation\n\nUsing [npm](https://www.npmjs.com/package/html-to-richtext-contentful):\n\n`npm i html-to-richtext-contentful`\n\n## Usage\n\n```\nimport { htmlToRichText } from 'html-to-richtext-contentful';\n\nconst html = '\u003ctable\u003e\u003ctr\u003e\u003cth\u003e\u003cp\u003eName\u003c/p\u003e\u003c/th\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003cp\u003eSodoTeo\u003c/p\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e';\nconst result = htmlToRichText(html);\n```\n\n## Output:\n\n```\n  {\n  \"nodeType\": \"document\",\n  \"data\": {},\n  \"content\": [\n    {\n      \"nodeType\": \"table\",\n      \"data\": {},\n      \"content\": [\n        {\n          \"nodeType\": \"table-row\",\n          \"data\": {},\n          \"content\": [\n            {\n              \"nodeType\": \"table-header-cell\",\n              \"data\": {},\n              \"content\": [\n                {\n                  \"nodeType\": \"paragraph\",\n                  \"data\": {},\n                  \"content\": [\n                    {\n                      \"nodeType\": \"text\",\n                      \"value\": \"Name\",\n                      \"marks\": [],\n                      \"data\": {}\n                    }\n                  ]\n                }\n              ]\n            }\n          ]\n        },\n        {\n          \"nodeType\": \"table-row\",\n          \"data\": {},\n          \"content\": [\n            {\n              \"nodeType\": \"table-cell\",\n              \"data\": {},\n              \"content\": [\n                {\n                  \"nodeType\": \"paragraph\",\n                  \"data\": {},\n                  \"content\": [\n                    {\n                      \"nodeType\": \"text\",\n                      \"value\": \"SodoTeo\",\n                      \"marks\": [],\n                      \"data\": {}\n                    }\n                  ]\n                }\n              ]\n            }\n          ]\n        }\n      ]\n    }\n  ]\n}\n```\n\n```\nconst { htmlToRichText } = require('html-to-richtext-contentfult');\n// id=\"\u003ccontentful-entry-id\u003e\"\nconst html = '\u003cp\u003e\u003centry-hyperlink id=\"main-nav-title-industry\"\u003etitle\u003c/entry-hyperlink\u003e\u003c/p\u003e';\nconst result = htmlToRichText(html);\n```\n\n```\n{\n  \"nodeType\": \"document\",\n  \"data\": {},\n  \"content\": [\n    {\n      \"nodeType\": \"paragraph\",\n      \"data\": {},\n      \"content\": [\n        {\n          \"nodeType\": \"entry-hyperlink\",\n          \"data\": {\n            \"target\": {\n              \"sys\": {\n                \"id\": \"main-nav-title-industry\",\n                \"type\": \"Link\",\n                \"linkType\": \"Entry\"\n              }\n            }\n          },\n          \"content\": [\n            {\n              \"nodeType\": \"text\",\n              \"value\": \"title\",\n              \"marks\": [],\n              \"data\": {}\n            }\n          ]\n        }\n      ]\n    }\n  ]\n}\n```\n\n## Note\n\nTo use hyperlinks as entry blocks, as well as embedded and inline entries and assets, you will need to render your custom node constructor and (most likely) Contentful's rich-[text-html-renderer](https://www.npmjs.com/package/@contentful/rich-text-html-renderer), [rich-text-types](https://www.npmjs.com/package/@contentful/rich-text-types). \nBelow is a snippet on how to do this:\n\n```\nimport { documentToHtmlString } from '@contentful/rich-text-html-renderer';\nimport { BLOCKS, INLINES } from '@contentful/rich-text-types';\n\nif (field.type === 'RichText') {\n    const options = {\n        renderNode: {\n            [BLOCKS.EMBEDDED_ENTRY]: (node) =\u003e\n                `\u003cembedded-entry id=\"${node.data.target.sys.id}\"/\u003e`,\n            [BLOCKS.EMBEDDED_ASSET]: (node) =\u003e\n                `\u003cembedded-asset id=\"${node.data.target.sys.id}\"/\u003e`,\n            [INLINES.EMBEDDED_ENTRY]: (node) =\u003e\n                `\u003cinline-entry id=\"${node.data.target.sys.id}\"/\u003e`,\n            [INLINES.ENTRY_HYPERLINK]: (node) =\u003e\n                `\u003centry-hyperlink id=\"${node.data.target.sys.id}\"\u003e${node.content[0].value}\u003c/entry-hyperlink\u003e`,\n            [INLINES.ASSET_HYPERLINK]: (node) =\u003e\n                `\u003casset-hyperlink id=\"${node.data.target.sys.id}\"\u003e${node.content[0].value}\u003c/asset-hyperlink\u003e`\n        }\n    };\n\n    if (field.values['en-US']) {\n        field.values['en-US'] = formatHTML(\n            documentToHtmlString(field.values['en-US'], options)\n        );\n    }\n\n    return field;\n}\n```\n\n## Git Repository\n\nhttps://github.com/SodoTeo/contentful-html-to-richtext\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsodoteo%2Fcontentful-html-to-richtext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsodoteo%2Fcontentful-html-to-richtext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsodoteo%2Fcontentful-html-to-richtext/lists"}