DOC to MD API
Send a Word 97-2003 file to POST /v2/convert/doc/to/md and get one UTF-8 Markdown file back. Heading styles become # lines, tables become pipe tables and bold text keeps its ** markers; pictures are left as a link to a file the response does not include.
- Endpoint
- POST /v2/
convert/ doc/ to/ md - Accepts
- doc
- Sample timing
- 23 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/doc/to/md \
-H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
-F File=@loan-agreement.doc \
-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
fiimport base64
import os
import requests
key = os.environ["PDFCONVERSIONAPI_KEY"]
response = requests.post(
"https://api.pdfconversionapi.com/v2/convert/doc/to/md",
headers={"Authorization": f"Bearer {key}"},
files=[("File", open("loan-agreement.doc", "rb"))],
timeout=180,
)
result = response.json()
if not response.ok:
raise SystemExit(f"{result['Code']}: {result['Message']}")
os.makedirs("converted", exist_ok=True)
for file in result["Files"]:
path = os.path.join("converted", file["FileName"])
with open(path, "wb") as out:
out.write(base64.b64decode(file["FileData"]))
print(path, file["FileSize"], "bytes")
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
const form = new FormData();
const file = "loan-agreement.doc";
form.append("File", new Blob([await readFile(file)]), file);
const url = "https://api.pdfconversionapi.com/v2/convert/doc/to/md";
const key = process.env.PDFCONVERSIONAPI_KEY;
const response = await fetch(url, {
method: "POST",
headers: { Authorization: `Bearer ${key}` },
body: form,
});
const result = await response.json();
if (!response.ok) {
throw new Error(`${result.Code}: ${result.Message}`);
}
await mkdir("converted", { recursive: true });
for (const file of result.Files) {
const path = join("converted", file.FileName);
await writeFile(path, Buffer.from(file.FileData, "base64"));
console.log(path, file.FileSize, "bytes");
}
{
"ConversionCost": 1,
"ConversionTime": 0.023,
"Files": [
{
"FileName": "loan-agreement.md",
"FileExt": "md",
"FileSize": 1079,
"FileData": "IVtdKGltYWdlLnBuZykKCiMg…"
}
]
}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.
loan-agreement.md, first 30 of 32 lines
# Equipment loan agreement# 1. PartiesThis agreement is between the Westpoint Harbor Sailing Club (the **club**) and the member named in section 4 (the **borrower**). Club rules are posted at [example.org/club-rules](https://example.org/club-rules).# 2. Equipment on loan| **Item** | **Serial number** | **Deposit (USD)** || :--- | :--- | :--- || Life jacket, adult | LJ-0412 | 40.00 || Dinghy mainsail, 6.9 m² | DS-117 | 150.00 || Hand-held VHF radio | VHF-08 | 90.00 || **Total deposit** | | **280.00** |# 3. Conditions1. Rinse all equipment in fresh water before you return it.2. Report any tear, crack or water in a radio within 24 hours.3. The deposit is refunded within 10 days of the return.Never leave a radio in a boat overnight.# 4. SignaturesBy signing, the borrower accepts the conditions in section 3.| Borrower | \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ | Date | \_\_\_\_\_\_\_\_\_\_\_\_ |
- Input
- loan-agreement.doc (26 KB)
- Output
- loan-agreement.md (1.1 KB)
- Source
- A two-page equipment loan agreement for a fictional sailing club, written for this site and saved in the Word 97-2003 format, with a shaded table, a footnote, a picture and page-numbered footers. (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.
| Parameter | What it does |
|---|---|
UpdateFieldsboolean, default false | Refresh fields before the text is written. With a table of contents in the file, the refreshed entries come out as links to anchors on the headings; the sample has none, so its output does not change. |
IncludeMarkupboolean, default false | Append the document's comments as a numbered list under a ## Comments heading, each with its author and the text it was attached to. The sample loan agreement has no comments, so it comes out the same. |
FileNamestring | Base name of the Markdown file; FileName=loan-terms returns loan-terms.md. |
StoreFileboolean, default false | Return a link to the .md file instead of its contents. Links expire after 3 hours. |
Not supported yet
Setting one of these to anything but its default returns 400.
| Option | What to do instead |
|---|---|
Images | Only the default, embed, is accepted, and the picture is not embedded today (see below). |
DetectHeadings | Headings come from Word heading styles; false returns 400. |
ListBulletChar | Bullets are written as -; another character returns 400. |
What carries over, and what doesn't
Kept
- Heading 1 paragraphs as
#lines ("# 1. Parties" through "# 4. Signatures"); the Title style also becomes# - The equipment table as a pipe table with left-alignment markers (
:---), its bold header and total rows kept as**…** - The numbered conditions as a
1.2.3.list - The hyperlink as
[example.org/club-rules](https://example.org/club-rules) - Bold words inside sentences, and characters outside ASCII such as m² in "6.9 m²"
- Signature lines typed with the
_character, each one escaped as\_so it is not read as emphasis
Lost or not yet supported
- The picture. The first line is
, but the response holds only the .md file, so the link points at nothing. - The footnote, the page header and the "page 1 of 2" footer.
- Color and underline: the red, underlined warning line is plain text.
- Table cell shading and borders, which Markdown has no syntax for.
Limits
- 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.
- A password-protected .doc gets 422 "the input file is password-protected" without
Passwordand 400 "password-protected DOC files can't be converted to MD yet" with it; on an unprotected filePasswordis ignored.
Where teams use it
Moving old policy documents into a docs repository
Handbooks and agreements written in Word 97 can be committed as Markdown and reviewed in pull requests. Heading levels and numbered clauses survive, so the outline still reads the same.
Feeding legacy files to a language model or search index
Markdown keeps the structure a model or a chunker needs (headings, table rows, list items) without the binary format. The sample's 26,112-byte .doc becomes 1,079 bytes of text.
Questions
Where are the images?
Not in the response yet. The Markdown refers to image.png, but only the .md file comes back, and Images=embed (ConvertAPI's default, which we accept) does not put the picture inline. If you need the pictures, convert to DOCX with /v2/convert/doc/to/docx and take them from word/media/.
Which Markdown flavor is it?
Tables use the pipe syntax from GitHub Flavored Markdown, so a renderer without table support shows them as plain lines. Everything else is CommonMark: # headings, 1. lists, **bold** and inline links.
How are headings decided?
From the paragraph styles in the .doc. The sample's four Heading 1 paragraphs and its Title paragraph each became a # line, and nothing else did. Bold words inside a paragraph stay inline **bold**. DetectHeadings=false is refused.
Why do the signature lines have backslashes?
The signature lines in the sample are runs of the _ character. Unescaped, Markdown would read them as emphasis markers, so each one is written as \_. A Markdown renderer shows them as a plain line again.
Convert your first DOC file in a minute.