Skip to content
pdfconversionapi

DOCX to TXT API

Send a Word file to POST /v2/convert/docx/to/txt and the response holds its body text as UTF-8 with Windows line endings. Lists keep their bullet or number followed by a tab, and each table row becomes one tab-separated line.

Endpoint
POST /v2/convert/docx/to/txt
Accepts
docx
Sample timing
22 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/docx/to/txt \
  -H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
  -F File=@volunteer-handbook.docx \
  -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 OK22 ms median1 file, 1.2 KB
{
  "ConversionCost": 1,
  "ConversionTime": 0.022,
  "Files": [
    {
      "FileName": "volunteer-handbook.txt",
      "FileExt": "txt",
      "FileSize": 1221,
      "FileData": "Vm9sdW50ZWVyIGhhbmRib29r…"
    }
  ]
}

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.

volunteer-handbook.txt, 28 lines

Volunteer handbookRiverside Tool Library, edition 3, spring 2027ContentsOpening the library	1Winter hours (removed)	3Opening the libraryVolunteers open the doors at 9:00 on Saturdays and 10:30 on weekdays. Read the opening checklist before your first shift.•	Unlock the front door and switch off the alarm.•	Turn on the dust collector.•	Check that the filter bag is less than half full.•	Count the cash box and write the total in the log.Shift scheduleDay	Hours	Lead volunteer	Tools outMonday	16:00 to 19:00	Amara Diallo	14Wednesday	16:00 to 19:00	Jonas Berg	22Saturday	9:00 to 14:00	Priya Shah	41Lending rules1.	Members borrow up to 3 tools at a time.2.	Power tools go out for 5 days, hand tools for 14.3.	Late returns pay $1 per tool per day.Checking tools back inScan the tool's barcode, look it over with the member, and put it on the return cart. Never shelve a tool you have not checked.Cleaning and sharpeningWipe blades with a dry cloth. Chisels and plane irons go in the sharpening bin by the bench grinder.Reporting damageTag the tool in red, write the problem on the tag, and add a line to the damage log. Do not try to repair power tools yourself.
Input
volunteer-handbook.docx (43 KB)
Output
volunteer-handbook.txt (1.2 KB)
Source
A two-page volunteer handbook for a fictional tool library, written for this site, with a stale table of contents, a footnote, a comment, a tracked change, a table and a 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
IncludeMarkupboolean, default falseAppend the comments after the text: a blank line, "Comments", another blank line, then one line per comment such as [1] Priya Shah on “Late returns pay $1 per tool per day.”: Board votes on the late fee in May.
UpdateFieldsboolean, default falseRegenerate the table of contents first, so the text lists the real headings (six lines for the sample) instead of the stale entries saved in the file.
UpdateTableOfContentsboolean, default falseThe same regeneration; UpdateReferences too.
PasswordstringPassword of an encrypted .docx. Wrong or missing: 422.
FileNamestringName for the text file; volunteer-handbook.txt by default.
StoreFileboolean, default falseGet a link valid for 3 hours instead of the text.

Not supported yet

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

OptionWhat to do instead
LineEndingCRLF only for now; crlf passes, lf returns 400.
SaveFormatUTF-8 (unicodetext) only; wintext returns 400.
InsertLineBreakstrue passes and false returns 400; paragraphs are never wrapped.
AllowSubstitutionsfalse passes, true returns 400.

What carries over, and what doesn't

Kept

  • Paragraphs in reading order, title and headings included, each on its own line with CRLF between lines (the last line has no line ending)
  • Bullets as "•" plus a tab and numbers as "1." plus a tab
  • Table rows as tab-separated lines: "Monday", "16:00 to 19:00", "Amara Diallo", "14"
  • The saved table of contents, with a tab before each page number
  • Tracked changes as accepted: "Power tools go out for 5 days"
  • A blank line where the page break was, and one where the banner picture was

Lost or not yet supported

  • The footnote, the header and the footer.
  • Comments, unless you send IncludeMarkup=true.
  • The link address behind "opening checklist", and all formatting.
  • List depth: the second-level bullet gets the same "•" and no extra indent.

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.
  • Encrypted files need Password; files protected with the older Office 2007 scheme can't be opened.

Where teams use it

Indexing uploads for full-text search

Store the text next to each uploaded .docx and index it. Table cells stay on their row, separated by tabs, so a search for a volunteer's name finds the row with their shift.

Input for language models and classifiers

Plain text with one paragraph per line is easy to count, split and send to a model. The sample's 44,003-byte DOCX is 1,221 bytes of text.

Diffing versions of a document

Compare the text of two revisions line by line in code review or an audit trail, without the XML noise of the DOCX package.

Questions

Can I choose LF line endings or Windows-1252?

Not yet. LineEnding=lf and SaveFormat=wintext return 400 instead of being ignored. The file is always UTF-8 without a byte order mark, with CRLF between lines.

Are headers, footers and footnotes included?

No. Only the body text is written, so "Handbook page 1 of 2" and the footnote about closed-toe shoes are missing from the sample's text. If you need them, /v2/convert/docx/to/pdf lays out the header and footer on every page and the footnote at the foot of page 1.

How do I get the comments too?

Add IncludeMarkup=true. The comments are appended at the end under a "Comments" line, numbered in square brackets, with author and the quoted text each one was attached to.

Convert your first DOCX file in a minute.