Skip to content
pdfconversionapi

HTML to DOCX API

POST an .html file to /v2/convert/html/to/docx and get a Word document back as base64 in the JSON. The 3,041-byte sample page became a 9,534-byte .docx with Heading 1 and Heading 2 paragraphs, a five-column table and its inlined picture, on Letter paper.

Endpoint
POST /v2/convert/html/to/docx
Accepts
html
Sample timing
25 ms median of 5 runsHow we measure
Request size
Up to 10 MB on the Free plan or 100 MB on paid plans, all files together

Request and response

Every sample below ran against the API before this page was published. Set PDFCONVERSIONAPI_KEY to your key and run it as is.

curl -sS -X POST \
  https://api.pdfconversionapi.com/v2/convert/html/to/docx \
  -H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
  -F File=@seed-swap.html \
  -o response.json

# FileData is base64. Save the first file in converted/,
# or print the JSON error.
if jq -e '.Files' response.json > /dev/null; then
  mkdir -p converted
  name=$(jq -r '.Files[0].FileName' response.json)
  jq -r '.Files[0].FileData' response.json \
    | base64 --decode > "converted/$name"
else
  cat response.json
fi
200 OK25 ms median1 file, 9.3 KB
{
  "ConversionCost": 1,
  "ConversionTime": 0.025,
  "Files": [
    {
      "FileName": "seed-swap.docx",
      "FileExt": "docx",
      "FileSize": 9534,
      "FileData": "UEsDBBQAAAAIAAAAIQCUHnBQ…"
    }
  ]
}

Response from our test run on 2026-11-03. ConversionTime shows the median of 5 runs. FileData is shortened here; the real response carries the whole file as base64.

The sample, converted

The same file the code sends. Download the input and the output and compare them yourself.

First page of seed-swap.docx, rendered by the API
Input
seed-swap.html (3.0 KB)
Output
seed-swap.docx (9.3 KB)
Source
A one-page web page for a fictional community seed library, written for this site: headings, a table, two lists, links, a quote, a style sheet, a script and an inlined picture. (CC0-1.0). How it was made
Made by
2026-11-04, API build 9eeeb0640aba

Parameters

Send these as form fields next to the file. Names are case-insensitive. If you set one of the documented options below that we don't support yet, the request fails with a 400 that names it instead of returning a file made without it.

ParameterWhat it does
FileNamestringBase name of the Word file. Without it the sample comes back as seed-swap.docx; FileName=swap-2027 gave swap-2027.docx.
StoreFileboolean, default falsetrue keeps the .docx on our side for 3 hours and returns a download link in Files[].Url instead of FileData.

Not supported yet

Setting one of these to anything but its default returns 400.

OptionWhat to do instead
MarginHorizontalConvertAPI's default of 1 passes. Any other value returns 400 "MarginHorizontal is not supported yet for HTML → DOCX"; the left and right margins are always 1 inch.
MarginVerticalSame rule for the top and bottom margins: only 1 is accepted.

What carries over, and what doesn't

Kept

  • Headings as Word heading styles: the sample's h1 and h2s became Heading 1 and Heading 2, and h3 and h4 in a test page became Heading 3 and Heading 4
  • Bold, italic, underline, strikethrough, superscript, subscript, <mark> (yellow shading) and <code> (Courier New)
  • The numbered steps and the bullets as Word lists: 1. for the steps, • for the bullets and ○ for the nested bullet
  • The table: 5 columns of 1.3 in, the header row set to repeat on every page, header cells bold
  • The inlined PNG unchanged (449 bytes) at 160 × 100 px, drawn 1.67 × 1.04 in
  • Both links as hyperlinks (the web address and the mailto:), and #anchor links as jumps to a bookmark
  • style attributes on elements: a test paragraph kept its color, Georgia font, 18 pt size and centering; a cell kept its gray fill and colspan
  • The page <title> and meta description as the document's title and description properties

Lost or not yet supported

  • Rules in <style> blocks and linked style sheets. The sample's Georgia body text, green h1 and table borders were not applied: body text is Aptos 12 pt and headings use the blue Heading style.
  • CSS table borders. The sample's table has no borders in the .docx; a <table border="1"> in a test page did get a grid.
  • Pictures by URL. Nothing is downloaded, so an <img> pointing to https://example.com/remote.png became its alt text.
  • Link styling. The links work, but their text is not blue or underlined.
  • Scripts and comments. The sample's script would have changed "Doors open at 10:00"; the .docx still says that, and the HTML comment is gone.
  • Form fields, which are dropped, and the meaning of <ins> and <del>: they become underlined and struck-through text, not tracked changes.
  • Page setup from the page. Every .docx we made was Letter, 8.5 × 11 in, with 1-inch margins.

Limits

  • One HTML file per request.
  • Requests up to 10 MB on the Free plan or 100 MB on paid plans, all files and fields together.
  • 120 seconds per conversion, then 504.
  • Only what is inside the file is used: linked pictures and style sheets are never fetched.

Where teams use it

Editable versions of generated reports

If your app renders letters, quotes or reports as HTML, send the same HTML here when someone wants to edit the text in Word. Headings arrive as Word heading styles rather than bold paragraphs, so the document keeps its structure.

Rich text from a web editor

Content typed into a browser editor is stored as HTML with bold, lists, links and inline style attributes. Converting it gives people a .docx attachment that keeps that formatting, including colors and fonts set on the elements.

Pages with embedded pictures

Pictures written into the page as data: URLs end up inside the .docx. That suits pages your code builds itself, where charts or logos can be inlined before the request.

Questions

Why doesn't my CSS show up in the Word file?

Only style attributes written on the elements are read. In a test page, style="color:#cc0000;font-family:Georgia" on a paragraph came through, while the same rules under a class selector in a <style> block did not. Inline the styles you need before you send the page.

Are images included?

Pictures in data: URLs are embedded as they are: the sample's 449-byte PNG is byte-identical in word/media/image1.png. Pictures by URL are not fetched and are replaced by their alt text, so inline them first.

Can I get A4 paper or other margins?

Not yet. Every document is Letter with 1-inch margins. ConvertAPI's MarginHorizontal and MarginVertical are accepted only at their default of 1; other values return 400 instead of a document with the wrong layout.

Does the page need to be UTF-8?

No. A test page saved as windows-1252 with <meta charset="windows-1252"> came out as "Café crème" in the .docx. Accented and non-Latin text in UTF-8 pages is kept too.

Convert your first HTML file in a minute.