{"id":50205397,"url":"https://github.com/arthrod/html-to-docx","last_synced_at":"2026-05-26T01:05:24.273Z","repository":{"id":358971363,"uuid":"1043586708","full_name":"arthrod/html-to-docx","owner":"arthrod","description":"Convert HTML to DOCX with structure and formatting preserved.","archived":false,"fork":false,"pushed_at":"2026-05-19T20:16:06.000Z","size":4694,"stargazers_count":0,"open_issues_count":26,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-19T23:52:06.517Z","etag":null,"topics":["conversion","document-processing","docx","html","office","ooxml","word"],"latest_commit_sha":null,"homepage":"https://TurboDocx.com","language":"JavaScript","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/arthrod.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"custom":["https://www.TurboDocx.com"]}},"created_at":"2025-08-24T07:17:21.000Z","updated_at":"2026-05-18T02:59:07.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/arthrod/html-to-docx","commit_stats":null,"previous_names":["arthrod/html-to-docx"],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/arthrod/html-to-docx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthrod%2Fhtml-to-docx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthrod%2Fhtml-to-docx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthrod%2Fhtml-to-docx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthrod%2Fhtml-to-docx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arthrod","download_url":"https://codeload.github.com/arthrod/html-to-docx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthrod%2Fhtml-to-docx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33499282,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-25T14:31:05.219Z","status":"ssl_error","status_checked_at":"2026-05-25T14:31:02.878Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["conversion","document-processing","docx","html","office","ooxml","word"],"created_at":"2026-05-26T01:05:23.229Z","updated_at":"2026-05-26T01:05:24.260Z","avatar_url":"https://github.com/arthrod.png","language":"JavaScript","funding_links":["https://www.TurboDocx.com"],"categories":[],"sub_categories":[],"readme":"[![TurboDocx](./banner.png)](https://www.turbodocx.com)\n\n@turbodocx/html-to-docx\n====================\n[![NPM Version][npm-image]][npm-url]\n[![CodeQL](https://github.com/TurboDocx/html-to-docx/workflows/CodeQL/badge.svg)](https://github.com/TurboDocx/html-to-docx/actions/workflows/codeql.yml)\n[![GitHub Stars](https://img.shields.io/github/stars/turbodocx/html-to-docx?style=social)](https://github.com/turbodocx/html-to-docx)\n[![Type Script](https://shields.io/badge/TypeScript-3178C6?logo=TypeScript\u0026logoColor=FFF\u0026style=flat-square)](https://typescript.org)\n[![Discord](https://img.shields.io/badge/Discord-Join%20Us-7289DA?logo=discord)](https://discord.gg/NYKwz4BcpX)\n[![npm](https://img.shields.io/npm/dm/@turbodocx/html-to-docx)](https://www.npmjs.com/package/@turbodocx/html-to-docx)\n[![X](https://img.shields.io/badge/X-@TurboDocx-1DA1F2?logo=x\u0026logoColor=white)](https://twitter.com/TurboDocx)\n[![Embed TurboDocx in Your App in Minutes](https://img.shields.io/badge/Embed%20TurboDocx%20in%20Your%20App%20in%20Minutes-8A2BE2)](https://www.turbodocx.com/use-cases/embedded-api?utm_source=github\u0026utm_medium=repo\u0026utm_campaign=open_source)\n\nConvert HTML to Word, Google Docs, and DOCX files with the fastest, most reliable JavaScript library available. Built for modern applications that demand speed and precision—from AI-powered document generation to enterprise reporting systems.\n\nBased on the original work and assisted by the original contributors of [privateOmega/html-to-docx](https://github.com/privateOmega/html-to-docx), this library is now actively maintained and enhanced by TurboDocx, ensuring continuous improvements and long-term support for production environments.\n\n## 🌐 Explore the TurboDocx Ecosystem\n\n| Package | Links | Description |\n|---------|-------|-------------|\n| API \u0026 SDK | [![Website](https://img.shields.io/badge/Website-TurboDocx-8A2BE2)](https://www.turbodocx.com/products/api-and-sdk) | Production-ready SDK for e-signature, document generation, template processing, and more |\n| TurboSign | [![Website](https://img.shields.io/badge/Website-TurboDocx-8A2BE2)](https://www.turbodocx.com/products/api-and-sdk) | Digital signature API for seamless e-signature workflows |\n| sdk | [![GitHub](https://img.shields.io/github/stars/turbodocx/sdk?style=social)](https://github.com/TurboDocx/sdk) | Official TurboDocx SDK for seamless API integration |\n| next-plugin-llms | [![GitHub](https://img.shields.io/github/stars/turbodocx/next-plugin-llms?style=social)](https://github.com/TurboDocx/next-plugin-llms) | Next.js plugin for automatic llms.txt generation |\n| n8n-nodes-turbodocx | [![npm](https://img.shields.io/npm/v/@turbodocx/n8n-nodes-turbodocx?logo=npm\u0026logoColor=white\u0026label=npm)](https://www.npmjs.com/package/@turbodocx/n8n-nodes-turbodocx) [![GitHub](https://img.shields.io/github/stars/turbodocx/n8n-nodes-turbodocx?style=social)](https://github.com/turbodocx/n8n-nodes-turbodocx) | n8n community node for TurboDocx API \u0026 TurboSign |\n\u003c!-- | turbodocx | [![npm](https://img.shields.io/npm/v/turbodocx?logo=npm\u0026logoColor=white\u0026label=npm)](https://www.npmjs.com/package/turbodocx) | TurboDocx Node.js SDK | --\u003e\n\u003c!-- | turbodocx-python | [![PyPI](https://img.shields.io/pypi/v/turbodocx?logo=python\u0026logoColor=white\u0026label=pypi)](https://pypi.org/project/turbodocx/) | TurboDocx Python SDK | --\u003e\n\u003c!-- | turbodocx-ruby | [![Gem](https://img.shields.io/gem/v/turbodocx?logo=ruby\u0026logoColor=white\u0026label=gem)](https://rubygems.org/gems/turbodocx) | TurboDocx Ruby SDK | --\u003e\n\n## Why @turbodocx/html-to-docx?\n\n🚀 **Lightning Fast Performance** - Pure JavaScript implementation with no dependencies on headless browsers or external binaries. Perfect for AI applications that need rapid document generation.\n\n🔄 **Active Maintenance \u0026 Support** - Backed by TurboDocx with regular updates, bug fixes, and feature enhancements. Not another abandoned open-source project.\n\n🤖 **AI-Ready Architecture** - Designed for modern AI workflows where speed matters. Generate thousands of documents without the overhead of browser automation.\n\n⚡ **Zero External Dependencies** - No need for Puppeteer, Chrome, or LibreOffice. Pure Node.js implementation that works in any environment.\n\n🎯 **Production Battle-Tested** - Used in production environments processing thousands of documents. Reliable, stable, and performant at scale.\n\n🛠️ **Developer Experience** - Full TypeScript support, comprehensive documentation, and extensive examples to get you up and running in minutes.\n\n## Installation\n\nUse the npm to install the project.\n\n```bash\nnpm install @turbodocx/html-to-docx\n```\n\n### TypeScript Support\n\nThis package includes TypeScript typings. No additional installation is required to use it with TypeScript projects.\n\n### TypeScript Example\n\n```typescript\nimport HtmlToDocx from \"@turbodocx/html-to-docx\";\n\nconst htmlString = `\u003c!DOCTYPE html\u003e\n    \u003chtml lang=\"en\"\u003e\n        \u003chead\u003e\n            \u003cmeta charset=\"UTF-8\" /\u003e\n            \u003ctitle\u003eDocument\u003c/title\u003e\n        \u003c/head\u003e\n        \u003cbody\u003e\n            \u003ch1\u003eHello world\u003c/h1\u003e\n        \u003c/body\u003e\n    \u003c/html\u003e`;\n\n// Basic usage\nasync function basicExample() {\n  const docx = await HtmlToDocx(htmlString);\n  // docx is ArrayBuffer in Node.js or Blob in browser environments\n}\n\n// With header\nasync function withHeader() {\n  const headerHtml = \"\u003cp\u003eDocument Header\u003c/p\u003e\";\n  const docx = await HtmlToDocx(htmlString, headerHtml);\n}\n\n// With document options\nasync function withOptions() {\n  const docx = await HtmlToDocx(htmlString, null, {\n    orientation: \"landscape\",\n    title: \"TypeScript Example\",\n    creator: \"TurboDocx\",\n    table: {\n      row: {\n        cantSplit: true,\n      },\n      borderOptions: {\n        size: 1,\n        color: \"000000\"\n      }\n    },\n    pageNumber: true,\n    footer: true\n  });\n}\n\n// With image processing options\nasync function withImageOptions() {\n  const htmlWithImages = `\u003cdiv\u003e\n    \u003cimg src=\"https://example.com/image.jpg\" alt=\"Example\"\u003e\n  \u003c/div\u003e`;\n  \n  const docx = await HtmlToDocx(htmlWithImages, null, {\n    imageProcessing: {\n      maxRetries: 3,          // Retry failed image downloads up to 3 times\n      verboseLogging: true,   // Enable detailed logging for debugging\n      downloadTimeout: 10000, // 10 second timeout per download attempt\n      maxImageSize: 5242880   // 5MB max image size\n    }\n  });\n}\n\n// With all parameters\nasync function complete() {\n  const headerHtml = \"\u003cp\u003eDocument Header\u003c/p\u003e\";\n  const footerHtml = \"\u003cp\u003ePage Footer\u003c/p\u003e\";\n  \n  const docx = await HtmlToDocx(\n    htmlString,\n    headerHtml,\n    {\n      orientation: \"landscape\",\n      pageSize: {\n        width: 12240,\n        height: 15840\n      },\n      margins: {\n        top: 1440,\n        right: 1800,\n        bottom: 1440,\n        left: 1800\n      },\n      title: \"Complete Example\",\n      creator: \"TurboDocx\",\n    },\n    footerHtml\n  );\n}\n```\n\nFor more comprehensive TypeScript examples, check out the following files in the `example/typescript` directory:\n\n- `typescript-example.ts` - A complete example showing how to generate and save DOCX files using TypeScript\n- `type-test.ts` - Demonstrates the type checking capabilities provided by the TypeScript definitions\n\n### Running the TypeScript Examples\n\nTo run the TypeScript examples:\n\n```bash\n# Navigate to the example directory\ncd example/typescript\n\n# Install ts-node globally (if not already installed)\nnpm install -g ts-node typescript\n\n# Ensure @turbodocx/html-to-docx is built and accessible\n# From the root directory of the project:\n# npm install\n# npm run build\n\n# Run the TypeScript example directly\nts-node typescript-example.ts\n```\n\nThis will generate two DOCX files in the `example/typescript` directory:\n- `basic-example.docx` - A simple document with minimal configuration\n- `advanced-example.docx` - A document with headers, footers, and advanced formatting options\n\n## Browser Standalone Build\n\nThe library provides a standalone browser build that bundles all dependencies into a single file. This allows you to use the library directly in HTML pages without any build tools or module bundlers.\n\n### Build Outputs\n\nWhen you run `npm run build`, three distribution files are generated:\n\n| File | Format | Size | Dependencies | Use Case |\n|------|--------|------|--------------|----------|\n| `dist/html-to-docx.esm.js` | ES Module | ~1.6 MB | External | Modern bundlers (Webpack, Vite, Rollup) |\n| `dist/html-to-docx.umd.js` | UMD | ~1.6 MB | External | Node.js, AMD, or manual dependency management |\n| `dist/html-to-docx.browser.js` | IIFE | ~2.4 MB | **All bundled** | Direct browser usage, CDN, quick prototypes |\n\n### Build Commands\n\n```bash\n# Build all versions (ESM + UMD + Browser)\nnpm run build\n\n# Build only the browser standalone version (development)\nnpm run build:browser\n\n# Build only the browser standalone version (production, minified)\nnpm run build:browser:prod\n```\n\n### Browser Usage\n\nInclude the standalone browser build directly in your HTML:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003eHTML to DOCX Demo\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003c!-- \n    Polyfills for Node.js globals (required)\n    Note: While rollup-plugin-polyfill-node bundles most Node.js polyfills,\n    these runtime globals must be set before the library loads because\n    some dependencies check for them synchronously during initialization.\n  --\u003e\n  \u003cscript\u003e\n    if (typeof global === 'undefined') window.global = window;\n    if (typeof process === 'undefined') window.process = { env: {} };\n    if (typeof Buffer === 'undefined') {\n      window.Buffer = {\n        from: function(data, encoding) {\n          if (typeof data === 'string') {\n            // Handle base64 and utf-8 encoding\n            if (encoding === 'base64') {\n              var binary = atob(data);\n              var bytes = new Uint8Array(binary.length);\n              for (var i = 0; i \u003c binary.length; i++) bytes[i] = binary.charCodeAt(i);\n              return bytes;\n            }\n            return new TextEncoder().encode(data);\n          }\n          return new Uint8Array(data);\n        },\n        isBuffer: function() { return false; }\n      };\n    }\n  \u003c/script\u003e\n  \n  \u003c!-- Include the standalone browser build --\u003e\n  \u003cscript src=\"path/to/html-to-docx.browser.js\"\u003e\u003c/script\u003e\n  \n  \u003cscript\u003e\n    async function generateDocument() {\n      const htmlContent = `\n        \u003ch1\u003eHello World\u003c/h1\u003e\n        \u003cp\u003eThis is a \u003cstrong\u003etest document\u003c/strong\u003e generated in the browser.\u003c/p\u003e\n      `;\n      \n      try {\n        const result = await HTMLToDOCX(htmlContent, null, {\n          title: 'My Document',\n          creator: 'Browser App'\n        });\n        \n        // Convert result to Blob for download\n        let blob;\n        if (result instanceof Blob) {\n          blob = result;\n        } else if (result instanceof ArrayBuffer || result instanceof Uint8Array) {\n          blob = new Blob([result], { \n            type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' \n          });\n        }\n        \n        // Trigger download\n        const url = URL.createObjectURL(blob);\n        const a = document.createElement('a');\n        a.href = url;\n        a.download = 'document.docx';\n        a.click();\n        URL.revokeObjectURL(url);\n      } catch (error) {\n        console.error('Error generating DOCX:', error);\n      }\n    }\n  \u003c/script\u003e\n  \n  \u003cbutton onclick=\"generateDocument()\"\u003eGenerate DOCX\u003c/button\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Testing the Browser Build\n\nA test page is included to verify the browser build works correctly:\n\n```bash\n# Build and start the test server\nnpm run test:browser\n```\n\nThen open http://localhost:8080/tests/test_browser.html in your browser.\n\nThe test page allows you to:\n- Edit HTML content in a textarea\n- Click \"Generate DOCX\" to create and download a Word document\n- See status messages for success or errors\n\n### CDN Usage\n\nYou can also host the browser build on a CDN for easy inclusion:\n\n```html\n\u003c!-- Example: Self-hosted or CDN --\u003e\n\u003cscript src=\"https://your-cdn.com/html-to-docx/1.18.1/html-to-docx.browser.js\"\u003e\u003c/script\u003e\n```\n\n### Limitations in Browser Environment\n\n- **Sharp (SVG conversion)**: The `sharp` image processing library is not available in browsers. SVG images will be embedded natively (requires Office 2019+).\n- **File System**: No direct file system access. Documents are returned as Blob/ArrayBuffer for download.\n- **Image URLs**: Remote images must be CORS-enabled or converted to base64 data URLs.\n\n## Usage\n\n```js\nawait HTMLtoDOCX(htmlString, headerHTMLString, documentOptions, footerHTMLString)\n```\n\nfull fledged examples can be found under `example/`\n\n### Parameters\n\n- `htmlString` \u003c[String]\u003e clean html string equivalent of document content.\n- `headerHTMLString` \u003c[String]\u003e clean html string equivalent of header. Defaults to `\u003cp\u003e\u003c/p\u003e` if header flag is `true`.\n- `documentOptions` \u003c?[Object]\u003e\n  - `orientation` \u003c\"portrait\"|\"landscape\"\u003e defines the general orientation of the document. Defaults to portrait.\n  - `pageSize` \u003c?[Object]\u003e Defaults to U.S. letter portrait orientation.\n    - `width` \u003c[Number]\u003e width of the page for all pages in this section in [TWIP]. Defaults to 12240. Maximum 31680. Supports equivalent measurement in [pixel], [cm] or [inch].\n    - `height` \u003c[Number]\u003e height of the page for all pages in this section in [TWIP]. Defaults to 15840. Maximum 31680. Supports equivalent measurement in [pixel], [cm] or [inch].\n  - `margins` \u003c?[Object]\u003e\n    - `top` \u003c[Number]\u003e distance between the top of the text margins for the main document and the top of the page for all pages in this section in [TWIP]. Defaults to 1440. Supports equivalent measurement in [pixel], [cm] or [inch].\n    - `right` \u003c[Number]\u003e distance between the right edge of the page and the right edge of the text extents for this document in [TWIP]. Defaults to 1800. Supports equivalent measurement in [pixel], [cm] or [inch].\n    - `bottom` \u003c[Number]\u003e distance between the bottom of text margins for the document and the bottom of the page in [TWIP]. Defaults to 1440. Supports equivalent measurement in [pixel], [cm] or [inch].\n    - `left` \u003c[Number]\u003e distance between the left edge of the page and the left edge of the text extents for this document in [TWIP]. Defaults to 1800. Supports equivalent measurement in [pixel], [cm] or [inch].\n    - `header` \u003c[Number]\u003e distance from the top edge of the page to the top edge of the header in [TWIP]. Defaults to 720. Supports equivalent measurement in [pixel], [cm] or [inch].\n    - `footer` \u003c[Number]\u003e distance from the bottom edge of the page to the bottom edge of the footer in [TWIP]. Defaults to 720. Supports equivalent measurement in [pixel], [cm] or [inch].\n    - `gutter` \u003c[Number]\u003e amount of extra space added to the specified margin, above any existing margin values. This setting is typically used when a document is being created for binding in [TWIP]. Defaults to 0. Supports equivalent measurement in [pixel], [cm] or [inch].\n  - `title` \u003c?[String]\u003e title of the document.\n  - `subject` \u003c?[String]\u003e subject of the document.\n  - `creator` \u003c?[String]\u003e creator of the document. Defaults to `html-to-docx`\n  - `keywords` \u003c?[Array]\u003c[String]\u003e\u003e keywords associated with the document. Defaults to ['html-to-docx'].\n  - `description` \u003c?[String]\u003e description of the document.\n  - `lastModifiedBy` \u003c?[String]\u003e last modifier of the document. Defaults to `html-to-docx`.\n  - `revision` \u003c?[Number]\u003e revision of the document. Defaults to `1`.\n  - `createdAt` \u003c?[Date]\u003e time of creation of the document. Defaults to current time.\n  - `modifiedAt` \u003c?[Date]\u003e time of last modification of the document. Defaults to current time.\n  - `headerType` \u003c\"default\"|\"first\"|\"even\"\u003e type of header. Defaults to `default`.\n  - `header` \u003c?[Boolean]\u003e flag to enable header. Defaults to `false`.\n  - `footerType` \u003c\"default\"|\"first\"|\"even\"\u003e type of footer. Defaults to `default`.\n  - `footer` \u003c?[Boolean]\u003e flag to enable footer. Defaults to `false`.\n  - `font` \u003c?[String]\u003e font name to be used. Defaults to `Times New Roman`.\n  - `fontSize` \u003c?[Number]\u003e size of font in HIP(Half of point). Defaults to `22`. Supports equivalent measure in [pt].\n  - `complexScriptFontSize` \u003c?[Number]\u003e size of complex script font in HIP(Half of point). Defaults to `22`. Supports equivalent measure in [pt].\n  - `table` \u003c?[Object]\u003e\n    - `row` \u003c?[Object]\u003e\n      - `cantSplit` \u003c?[Boolean]\u003e flag to allow table row to split across pages. Defaults to `false`.\n    - `borderOptions` \u003c?[Object]\u003e\n      - `size` \u003c?[Number]\u003e denotes the border size. Defaults to `0`.\n      - `stroke` \u003c?[String]\u003e denotes the style of the borderStrike. Defaults to `nil`.\n      - `color` \u003c?[String]\u003e determines the border color. Defaults to `000000`.\n    - `addSpacingAfter` \u003c?[Boolean]\u003e flag to add an empty paragraph after tables for spacing. Defaults to `true`.\n  - `pageNumber` \u003c?[Boolean]\u003e flag to enable page number in footer. Defaults to `false`. Page number works only if footer flag is set as `true`.\n  - `skipFirstHeaderFooter` \u003c?[Boolean]\u003e flag to skip first page header and footer. Defaults to `false`.\n  - `lineNumber` \u003c?[Boolean]\u003e flag to enable line numbering. Defaults to `false`.\n  - `lineNumberOptions` \u003c?[Object]\u003e\n    - `start` \u003c[Number]\u003e start of the numbering - 1. Defaults to `0`.\n    - `countBy` \u003c[Number]\u003e skip numbering in how many lines in between + 1. Defaults to `1`.\n    - `restart` \u003c\"continuous\"|\"newPage\"|\"newSection\"\u003e numbering restart strategy. Defaults to `continuous`.\n  - `numbering` \u003c?[Object]\u003e\n    - `defaultOrderedListStyleType` \u003c?[String]\u003e default ordered list style type. Defaults to `decimal`.\n  - `heading` \u003c?[Object]\u003e custom heading styles configuration\n  - `heading1`-`heading6` \u003c?[Object]\u003e heading style configuration\n    - `font` \u003c?[String]\u003e font family\n    - `fontSize` \u003c?[Number]\u003e font size in half-points\n    - `bold` \u003c?[Boolean]\u003e whether text is bold. Defaults to `true`\n    - `spacing` \u003c?[Object]\u003e paragraph spacing configuration\n      - `before` \u003c?[Number]\u003e spacing before heading in twips\n      - `after` \u003c?[Number]\u003e spacing after heading in twips\n    - `keepLines` \u003c?[Boolean]\u003e keep lines together. Defaults to `true`\n    - `keepNext` \u003c?[Boolean]\u003e keep with next paragraph. Defaults to `true`\n    - `outlineLevel` \u003c?[Number]\u003e outline level (0-5)\n  - `decodeUnicode` \u003c?[Boolean]\u003e flag to enable unicode decoding of header, body and footer. Defaults to `false`.\n  - `lang` \u003c?[String]\u003e language localization code for spell checker to work properly. Defaults to `en-US`.\n  - `direction` \u003c?[String]\u003e text direction for RTL (right-to-left) languages. Set to `'rtl'` for Arabic, Hebrew, etc. Defaults to `'ltr'`.\n  - `preProcessing` \u003c?[Object]\u003e\n    - `skipHTMLMinify` \u003c?[Boolean]\u003e flag to skip minification of HTML. Defaults to `false`.\n  - `imageProcessing` \u003c?[Object]\u003e\n    - `maxRetries` \u003c?[Number]\u003e maximum number of retry attempts for failed image downloads. Defaults to `2`.\n    - `verboseLogging` \u003c?[Boolean]\u003e flag to enable detailed logging of image processing operations. Defaults to `false`.\n    - `downloadTimeout` \u003c?[Number]\u003e timeout in milliseconds for each image download attempt. Defaults to `5000` (5 seconds).\n    - `maxImageSize` \u003c?[Number]\u003e maximum allowed image size in bytes. Defaults to `10485760` (10MB).\n    - `retryDelayBase` \u003c?[Number]\u003e base delay in milliseconds for exponential backoff between retries. Defaults to `500` (500ms).\n    - `minTimeout` \u003c?[Number]\u003e minimum timeout in milliseconds. Defaults to `1000` (1 second).\n    - `maxTimeout` \u003c?[Number]\u003e maximum timeout in milliseconds. Defaults to `30000` (30 seconds).\n    - `minImageSize` \u003c?[Number]\u003e minimum image size in bytes. Defaults to `1024` (1KB).\n    - `maxCacheSize` \u003c?[Number]\u003e maximum total cache size in bytes (LRU cache limit to prevent OOM). Defaults to `20971520` (20MB).\n    - `maxCacheEntries` \u003c?[Number]\u003e maximum number of unique images in cache (LRU eviction). Defaults to `100`.\n    - `svgHandling` \u003c?[String]\u003e strategy for handling SVG images. Defaults to `'convert'`. Options:\n      - `'convert'` - Converts SVG to PNG for maximum compatibility with all Word versions (requires `sharp` package)\n      - `'native'` - Embeds SVG natively for Office 2019+ (preserves vector quality)\n- `footerHTMLString` \u003c[String]\u003e clean html string equivalent of footer. Defaults to `\u003cp\u003e\u003c/p\u003e` if footer flag is `true`.\n\n### Returns\n\n\u003c[Promise]\u003c[Buffer]|[Blob]\u003e\u003e\n\n## Notes\n\nCurrently page break can be implemented by having div with classname \"page-break\" or style \"page-break-after\" despite the values of the \"page-break-after\", and contents inside the div element will be ignored. `\u003cdiv class=\"page-break\" style=\"page-break-after: always;\"\u003e\u003c/div\u003e`\n\n\nCSS list-style-type for `\u003col\u003e` element are now supported. Just do something like this in the HTML:\n```\n  \u003col style=\"list-style-type:lower-alpha;\"\u003e\n    \u003cli\u003eList item\u003c/li\u003e\n    ...\n  \u003c/ol\u003e\n```\nList of supported list-style-types:\n- upper-alpha, will result in `A. List item`\n- lower-alpha, will result in `a. List item`\n- upper-roman, will result in `I. List item`\n- lower-roman, will result in `i. List item`\n- lower-alpha-bracket-end, will result in `a) List item`\n- decimal-bracket-end, will result in `1) List item`\n- decimal-bracket, will result in `(1) List item`\n- decimal, **(the default)** will result in `1. List item`\n\nAlso you could add attribute `data-start=\"n\"` to start the numbering from the n-th.\n\n`\u003col data-start=\"2\"\u003e` will start the numbering from ( B. b. II. ii. 2. )\n\n\n## SVG Image Support\n\nThe library provides comprehensive SVG image support with two strategies to fit your needs:\n\n### Installation \u0026 Package Size\n\nThe library supports SVG images with [`sharp`](https://sharp.pixelplumbing.com/) as an optional peer dependency for high-quality SVG→PNG conversion.\n\n**Basic Installation** (Lightweight):\n```bash\nnpm install @turbodocx/html-to-docx\n```\n- **Package size**: ~2.8MB (sharp not included)\n- **Compatibility**: SVGs embedded natively - requires Office 2019+ or Microsoft 365\n- **Best for**: Modern-only environments or size-constrained deployments (Lambda, Edge)\n- **Auto-fallback**: Library automatically uses native SVG mode when sharp is unavailable\n\n**Full Installation** (Maximum Compatibility - Recommended):\n```bash\nnpm install @turbodocx/html-to-docx sharp\n```\n- **Base package**: ~2.8MB\n- **With sharp**: Additional ~34MB (platform-specific native binaries)\n- **Compatibility**: Converts SVGs to PNG - works with all Word versions (2007+)\n- **Best for**: Production applications requiring broad compatibility\n\n#### Why is sharp optional?\n\nSharp is a native Node.js module that provides the best SVG to PNG conversion quality, but adds ~34MB of platform-specific native binaries to your `node_modules`. We've made it an optional peer dependency so you can choose:\n\n| Configuration | Install Command | Size | SVG Handling | Word Compatibility | Use Case |\n|--------------|-----------------|------|--------------|-------------------|----------|\n| **Without sharp** (default) | `npm install @turbodocx/html-to-docx` | 2.8MB | Native SVG | Office 2019+ only | Modern environments, Lambda/edge functions |\n| **With sharp** (recommended) | `npm install @turbodocx/html-to-docx sharp` | 2.8MB + 34MB binaries | PNG conversion | All versions (2007+) | Production apps, broad compatibility |\n\nThe library **gracefully handles both scenarios** - if sharp is unavailable, SVGs are automatically embedded in native format.\n\n### 1. Convert to PNG (Default - Maximum Compatibility)\n\nBy default, SVG images are automatically converted to PNG format for maximum compatibility with all Word versions (requires `sharp`):\n\n```javascript\nconst htmlWithSVG = `\n  \u003cdiv\u003e\n    \u003cimg src=\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIj48Y2lyY2xlIGN4PSI1MCIgY3k9IjUwIiByPSI0MCIgZmlsbD0iIzM0OThkYiIvPjwvc3ZnPg==\" alt=\"Circle\"\u003e\n  \u003c/div\u003e\n`;\n\n// Default behavior - SVG converted to PNG\nconst docx = await HTMLtoDOCX(htmlWithSVG);\n\n// Or explicitly set to convert\nconst docx = await HTMLtoDOCX(htmlWithSVG, null, {\n  imageProcessing: {\n    svgHandling: 'convert'  // Converts SVG to PNG (default)\n  }\n});\n```\n\n**Benefits:**\n- ✅ Works with all Word versions (2007+)\n- ✅ Compatible with Word Online, Google Docs, LibreOffice\n- ✅ No compatibility warnings or errors\n\n### 2. Native SVG (Office 2019+ Only)\n\nFor modern Office environments, you can embed SVG images natively to preserve vector quality:\n\n```javascript\nconst htmlWithSVG = `\n  \u003cdiv\u003e\n    \u003cimg src=\"data:image/svg+xml;base64,...\" alt=\"Vector Graphic\"\u003e\n  \u003c/div\u003e\n`;\n\nconst docx = await HTMLtoDOCX(htmlWithSVG, null, {\n  imageProcessing: {\n    svgHandling: 'native'  // Embed SVG natively (Office 2019+)\n  }\n});\n```\n\n**Benefits:**\n- ✅ Perfect vector quality at any zoom level\n- ✅ Smaller file sizes for complex graphics\n- ✅ Editable in modern Office applications\n\n**Requirements:**\n- Microsoft Office 2019 or later\n- Microsoft 365\n- Word for Mac 2019+\n\n**Note:** Older Word versions will show an \"unreadable content\" error with native SVG. Use `'convert'` mode for backwards compatibility.\n\n### Handling SVG Without Sharp\n\nIf `sharp` is not installed (e.g., using `--no-optional`), the library automatically falls back to native SVG embedding:\n\n```javascript\n// Even with svgHandling: 'convert', if sharp unavailable → uses native SVG\nconst docx = await HTMLtoDOCX(htmlWithSVG, null, {\n  imageProcessing: {\n    svgHandling: 'convert',         // Tries to convert, falls back to native\n    suppressSharpWarning: false,    // Set to true to suppress warning when sharp is missing\n    verboseLogging: true            // Shows: \"Sharp not available, using native SVG\"\n  }\n});\n```\n\n**No crashes, no errors** - the library detects sharp availability at runtime and adjusts automatically:\n\n```bash\n# With sharp installed\n✅ SVG → PNG conversion → Works in Word 2007+\n\n# Without sharp (--no-optional)\nℹ️  SVG → Native embedding → Works in Office 2019+ only\n\n# Suppress the warning (if intentionally using native SVG mode)\nimageProcessing: { suppressSharpWarning: true }\n```\n\n**Pro tip**: For serverless/Lambda deployments with size constraints, install without sharp and set `suppressSharpWarning: true` to avoid console warnings. Document that generated files require Office 2019+.\n\n## RTL (Right-to-Left) Language Support\n\nThe library also supports RTL languages like Arabic and Hebrew. Use the `direction` option to enable RTL text flow:\n\n```javascript\nconst htmlString = `\n  \u003ch1\u003eمرحبا بالعالم\u003c/h1\u003e\n  \u003cp\u003eهذا نص تجريبي باللغة العربية ليظهر من اليمين إلى اليسار\u003c/p\u003e\n`;\n\nconst docx = await HTMLtoDOCX(htmlString, null, {\n  direction: 'rtl',        // Enable RTL text direction\n  lang: 'ar-SA',          // Arabic locale (or 'he-IL' for Hebrew)\n  font: 'Arial',          // Use a font that supports RTL characters\n});\n```\n\nFor more RTL examples, check `example/react-example/src/example-rtl.js`.\n\n## Font Compatibility\n\nFont family doesnt work consistently for all word processor softwares\n\n- Word Desktop work as intended\n- LibreOffice ignores the fontTable.xml file, and finds a font by itself\n- Word Online ignores the fontTable.xml file, and finds closest font in their font library\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to branch new branches off of develop for contribution.\n\n## Support\n**Proudly Sponsored by TurboDocx** \n[![\"Proudly Sponsored by TurboDocx\"](https://image.typedream.com/cdn-cgi/image/width=1920,format=auto,fit=scale-down,quality=100/https://api.typedream.com/v0/document/public/de39171b-a5c9-49c5-bd9c-c2dfd5d632a2/2PZxyx12UwC5HrIA3p6lo16fCms_Group_16_1_.png)](https://www.TurboDocx.com)\n\n## License\n\nMIT\n\n[npm-image]: https://img.shields.io/npm/v/@turbodocx/html-to-docx.svg\n[npm-url]: https://npmjs.org/package/@turbodocx/html-to-docx\n[html-docx-js]: https://github.com/evidenceprime/html-docx-js \"html-docx-js\"\n[altchunks]: https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.altchunk?view=openxml-2.8.1 \"altchunks\"\n[libtidy]: https://github.com/jure/node-libtidy \"libtidy\"\n[String]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type \"String\"\n[Object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object \"Object\"\n[Number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type \"Number\"\n[TWIP]: https://en.wikipedia.org/wiki/Twip \"TWIP\"\n[Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array \"Array\"\n[Date]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date \"Date\"\n[Boolean]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type \"Boolean\"\n[Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise \"Promise\"\n[Buffer]: https://nodejs.org/api/buffer.html#buffer_buffer \"Buffer\"\n[Blob]: https://developer.mozilla.org/en-US/docs/Web/API/Blob \"Blob\"\n[pixel]: https://en.wikipedia.org/wiki/Pixel#:~:text=Pixels%2C%20abbreviated%20as%20%22px%22,what%20screen%20resolution%20views%20it. \"pixel\"\n[cm]: https://en.wikipedia.org/wiki/Centimetre \"cm\"\n[inch]: https://en.wikipedia.org/wiki/Inch \"inch\"\n[pt]: https://en.wikipedia.org/wiki/Point_(typography) \"pt\"\n\n## Contributors\n\n\u003ca href=\"https://github.com/TurboDocx/html-to-docx/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=turbodocx/html-to-docx\" /\u003e\n\u003c/a\u003e\n\nMade with [contrib.rocks](https://contrib.rocks).\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n[![TurboDocx](./footer.png)](https://www.turbodocx.com)\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farthrod%2Fhtml-to-docx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farthrod%2Fhtml-to-docx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farthrod%2Fhtml-to-docx/lists"}