Word to PDF API
The Word to PDF API converts Microsoft Word documents to PDF. Send a .docx or .doc file, as an upload or a link, and get back a PDF with the document's text, fonts, headings, tables, images, lists, headers and footers, footnotes and page numbers, on the same page size and margins.
Common Office fonts that a document uses but does not embed, such as Calibri, Cambria, Arial and Times New Roman, are replaced with fonts that have the same character widths, so text keeps close to its original line and page breaks. Macros in a document never run.
Use it to turn contracts, invoices, reports and letters generated as Word files into PDFs for sharing, printing, archiving or e-signature.
Each page of the PDF uses one of your plan's monthly document pages, not API calls: Free 50, Developer 10,000, Business 100,000, Professional 500,000. The X-Pages-Used and X-Pages-Remaining response headers show the pages each request used and how many are left. See pricing.
Working with images? The Image to PDF API combines images into a PDF, the PDF to Image API turns PDF pages into images, and the Image to Text API reads the text in an image.
Available endpoint:
- /v1/wordtopdf - Convert a Word document to PDF
At a Glance
| Input | .docx or .doc: upload, raw body, or url (up to about 4 MB) |
|---|---|
| Output | A PDF, as base64 in JSON or as a PDF file |
| Pages per document | Up to 100 |
| Plan usage | 1 document page per page of the PDF |
| Free plan | Documents up to 3 pages and 2 MB |
Related APIs
- PDF to Image API - PDF pages to JPG, PNG or WebP images
- PDF to JPG API - PDF pages to JPG images
- PDF to PNG API - PDF pages to lossless PNG images
- Image to PDF API - JPG, PNG and other images to one PDF
- JPG to PDF API - JPG photos and scans to one PDF
- PNG to PDF API - PNG screenshots and charts to one PDF
- Image to Text API - Read the text in an image (OCR)
https://api.api-ninjas.com/v1/wordtopdf
Converts a Word document (.docx or .doc) to PDF. Returns the PDF as base64 in JSON, or as a raw PDF file. Accepts GET or POST: use POST to upload a document, or GET with url.
Parameters
Send the document as a file upload (multipart form data), as a url link, or as the raw request body with its Content-Type.
fileoptionalThe Word document (
.docxor.doc), as a multipart form upload, up to about 4 MB.urloptionalA public
http://orhttps://link to a.docxor.docfile, up to about 4 MB, instead of an upload. Works with GET or POST.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Acceptoptionalapplication/pdfreturns the raw PDF file instead of JSON.Content-Typeoptionalapplication/vnd.openxmlformats-officedocument.wordprocessingml.document(.docx) orapplication/msword(.doc), when the request body is the document itself. Multipart uploads set their own content type.
Response
The /v1/wordtopdf endpoint returns a JSON object with the following fields, or an error if the request is unsuccessful (see errors).
page_countNumber of pages in the PDF.
sizeSize of the PDF in bytes.
pdfThe PDF file, base64-encoded.
With Accept: application/pdf, the response body is the PDF file itself (Content-Type: application/pdf). Responses have X-Pages-Used (document pages the request used) and X-Pages-Remaining (document pages left this month) headers.
Limits
- Documents up to 100 pages and about 4 MB, uploaded or from
url. - The PDF can be up to about 4 MB.
- One document per request. Password-protected documents are not supported.
- Free plan: documents up to 3 pages and 2 MB, sent as file uploads.
Document pages
This API uses your plan's monthly document pages, not API calls. Each page of the PDF uses one: a 10-page document uses 10.
Live Demo
The demo converts this sample document. Sign up or log in to convert your own Word documents.
Get a free API key to get started — no credit card required.
Press Send to convert the document and preview the PDF here.
Code Examples
# Convert a Word document and save the PDF
curl -X POST "https://api.api-ninjas.com/v1/wordtopdf" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Accept: application/pdf" \
-F "file=@report.docx" \
--output report.pdfErrors
An invalid request returns HTTP 400 with a JSON body holding a readable error message. If too many documents are being converted at once, the API returns HTTP 503: retry after a few seconds. Authentication and quota errors use the standard format described in error codes.
| Cause | Example error |
|---|---|
| No document in the request | Send the Word document as file (a multipart form upload) or as url (a link to the document). |
| A file that is not a Word document | Unsupported file type. Send a Word document (.docx or .doc). |
| A damaged or password-protected document | The document could not be converted. Check that it is a valid Word document and is not password-protected. |
| More than 100 pages | This document has 140 pages. The most per request is 100 pages. |
| A document over about 4 MB | The file is larger than 4 MB. Send a smaller document. |
| A PDF over about 4 MB | The PDF would be larger than 4 MB. Try a document with fewer or smaller images. |
| More than one document | Send one document per request. |
| No document pages left this month | You have used all 50 document pages included in your Free plan this month. They renew on December 1, 2026. Upgrade at https://api-ninjas.com/pricing for more. |
| Free plan: more than 3 pages | This document has 5 pages. The Free plan converts documents of up to 3 pages. Upgrade at https://api-ninjas.com/pricing for documents up to 100 pages. |
Frequently Asked Questions
Can I use the Word to PDF API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the Word to PDF API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.How do I get an API key and start using the Word to PDF API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.What happens if a request to the Word to PDF API fails?
The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.How do I convert a Word document to PDF with an API?
POST the document to/v1/wordtopdfas a multipart upload namedfile, e.g.curl -X POST "https://api.api-ninjas.com/v1/wordtopdf" -H "X-Api-Key: YOUR_API_KEY" -H "Accept: application/pdf" -F "file=@report.docx" --output report.pdf. Without theAcceptheader the response is JSON with the PDF base64-encoded inpdf. A document that is already online can be passed asurlinstead.Which Word formats can I convert?
.docxfiles (Word 2007 and later) and.docfiles (Word 97 to 2003). The file type is read from the file itself, so the file name does not matter. Password-protected documents are not supported, and macros in a document never run.Will the PDF look like the Word document?
Text, headings, fonts, tables, images, lists, headers and footers, footnotes and page numbers are converted, on the document's own page size and margins. Fonts embedded in the document are used as they are. Common Office fonts that are not embedded, such as Calibri, Cambria, Arial, Times New Roman and Courier New, are replaced with fonts that have the same character widths, so text keeps close to its original line and page breaks.How much of my plan does a conversion use?
No API calls. Each page of the PDF uses one of your plan's monthly document pages, so a 10-page document uses 10. TheX-Pages-UsedandX-Pages-Remainingresponse headers show the pages each request used and how many are left.Can I convert Word to PDF on the Free plan?
Yes: the Free plan includes 50 document pages a month, for documents up to 3 pages and 2 MB sent as file uploads. Paid plans convert documents up to 100 pages and about 4 MB, from uploads orurl, with 10,000 to 500,000 document pages a month. See pricing.
Explore API integration use cases for recommended APIs and workflow examples.