Markdown to Word API

Convert Markdown or HTML to an editable Word .docx with real styles, lists, tables, code, images, page size, margins, page numbers and a Decree 30 preset.

POSThttps://apibox.io.vn/v1/md-docx

Send markdown (GitHub-flavoured: headings, bold / italic / strikethrough, inline code, links, nested bullet and numbered lists, task lists, tables with alignment, block quotes, code blocks, horizontal rules, images) or html and get a .docx built with real Word styles (Heading 1-6, List Paragraph, Quote, Source Code), so the navigation pane, table of contents and style changes work as in a hand-made document. Numbered lists keep their start number; table header rows repeat on each page.

Presets: default (Calibri 11, 2.54 cm margins), report (Arial, justified) and nd30 for Vietnamese administrative documents under Decree 30/2020/NĐ-CP: A4, Times New Roman 14 pt (13 with font_size=13), margins top / bottom 20 mm, left 30 mm, right 15 mm, justified text, first line indented 1.27 cm, 6 pt between paragraphs, page numbers centred in the top margin and hidden on the first page. Override any of font, font_size, line_spacing, margins (mm, "top,right,bottom,left"), page (a4, a5, a3, letter, legal), orientation, page_numbers, header_text, footer_text, first_line_indent; toc=true adds a table of contents field that Word fills when the file is opened.

Images can be data URLs or public http(s) URLs (PNG, JPEG, GIF; up to 20 fetched, 5 MB each) and are scaled to the text width. The output is a .docx file, or JSON with base64 (format=json). Files are generated in memory and not stored.

Markdown · OpenAPI · Postman · llms.txt

Parameters

NameInTypeRequiredDefault
markdownbodystringyesMarkdown text (or a text/plain body). Or send html.
htmlbodystringnoHTML instead of Markdown (converted first).
presetbodystringnodefaultdefault, report or nd30 (Decree 30/2020).
fontbodystringnoFont name, e.g. Times New Roman.
font_sizebodynumbernoBody size in points (6-48).
line_spacingbodynumbernoLine spacing in lines (0.8-3).
marginsbodystringnoMillimetres: top,right,bottom,left, one value, or an object.
pagebodystringnoa4a4, a5, a3, letter or legal.
orientationbodystringnoportraitportrait or landscape.
page_numbersbodystringnonone, footer or header (preset default).
tocbodybooleannofalseInsert a table of contents field.
header_textbodystringnoText in the page header.
footer_textbodystringnoText in the page footer.
formatbodystringnodocxdocx (file) or json (base64 + summary).

Example

curl -X POST "https://apibox.io.vn/v1/md-docx" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"markdown":"# Báo cáo tuần\n\nNội dung **chính**.\n\n- Việc 1\n- Việc 2\n\n| Hạng mục | Tiến độ |\n|---|---:|\n| API | 90% |","preset":"nd30","format":"json"}'

Response

{
  "filename": "Báo cáo tuần.docx",
  "preset": "nd30",
  "page": {
    "size": "a4",
    "orientation": "portrait",
    "margins_mm": {
      "top": 20,
      "right": 15,
      "bottom": 20,
      "left": 30
    }
  },
  "font": "Times New Roman",
  "font_size": 14,
  "paragraphs": 6,
  "images": 0,
  "links": 0,
  "warnings": [],
  "docx_base64": "UEsDBBQAAAgIAAAAAADpEG/9ZAEAALkFAAATAAAAW0NvbnRlbnRfVHlwZXNd…",
  "bytes": 5587
}

Use cases

  • Turn AI-generated Markdown reports into Word files for clients
  • Produce Decree 30 formatted drafts for Vietnamese agencies and schools
  • Export Notion / Obsidian notes or CMS HTML to .docx
  • Generate weekly reports with tables and charts as images

FAQ

Does it follow Decree 30/2020 completely?

preset=nd30 applies the page, font, spacing, indentation and page-number rules of Annex I. The national motto block, document number and signature layout are content you write; check the final document against the decree.

Can I convert Word back to Markdown?

Yes, with /v1/docx-convert.

Why is the table of contents empty at first?

A TOC is a Word field: Word asks to update fields when the file opens (or press F9). Other editors may show the placeholder text.

Related APIs

Start with 1,000 free requests every month. Get free API key →