PDF to DOCX Node.js API
Convert PDF files to DOCX using our Node.js PDF to DOCX API.
Preserve layout and formatting
Accurately convert text, headings, tables, and styles into Office format while maintaining the structure of the original PDF.
Automate with Zapier
Automatically convert PDF files in Google Drive to Office files using our Zapier integration. A no-code workflow to instantly create editable Word documents from PDFs.
Edit without starting over
Quickly edit or repurpose content from PDFs directly in Office files.
Nutrient is used by
Try it out
This example will convert your uploaded PDF file to a DOCX.
Use Your Free API Calls
Sign up and receive 100 credits for free, or log in to automatically add your API key to sample code. If you are not sure how credits are consumed read more in our pricing documentation , or check out this guide on calculating credit usage.
Add a File
Add a PDF file named input.pdf
to your project folder. You can also use our sample file.
The file name is case sensitive. Make sure the file name matches the file name in the sample code.
Run the Code
Copy the code and run it from the same folder you added the files to. For more information, see our language-specific getting started guides.
View the Results
Open
result.docx
in your project folder to view the results.
// This code requires Node.js. Do not run this code directly in a web browser.
const axios = require('axios')
const FormData = require('form-data')
const fs = require('fs')
const formData = new FormData()
formData.append('instructions', JSON.stringify({
parts: [
{
file: "file"
}
],
output: {
type: "docx"
}
}))
formData.append('file', fs.createReadStream('input.pdf'))
;(async () => {
try {
const response = await axios.post('https://api.nutrient.io/build', formData, {
headers: formData.getHeaders({
'Authorization': 'Bearer your_api_key_here'
}),
responseType: "stream"
})
response.data.pipe(fs.createWriteStream("result.docx"))
} catch (e) {
const errorString = await streamToString(e.response.data)
console.log(errorString)
}
})()
function streamToString(stream) {
const chunks = []
return new Promise((resolve, reject) => {
stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)))
stream.on("error", (err) => reject(err))
stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")))
})
}
Your API Key
Get access to your API key when you create an account. Once your account has been created, you’ll get 100 credits for free.
Your API key has automatically been inserted into the API example code. Run the sample code in your terminal to execute the API call.
Security is our top priority
No document storage
No input or resulting documents are stored on our infrastructure. All files are deleted as soon as a request finishes. Alternatively, check out our self-hosted product.
HTTPS encryption
All communication between your application and Nutrient is done via HTTPS to ensure your data is encrypted when it’s sent to us.
Safe payment processing
All payments are handled by Paddle. Nutrient DWS Processor API never has direct access to any of your payment data.