JavaScript Library

ConvertAPI JavaScript Client

Convert your files with our online file conversion API

The ConvertAPI helps converting various file formats. Creating PDF and Images from various sources like Word, Excel, Powerpoint, images, web pages. Merge, Encrypt, Split, Repair and Decrypt PDF files. And many others files manipulations. In just few minutes you can integrate it into your application and use it easily.

The ConvertAPI-JS library makes it easier to use the Convert API from your web projects without having to build your own API calls. You can get your free API secret at


Run this line from console:

npm i convertapi-js

Or import from the CDN:

<script src=""></script>



You can get your secret at

let convertApi = ConvertApi.auth({secret: '<YOUR_SECRET>'})

File conversion

Example to convert DOCX file to PDF. All supported formats and options can be found here.

let params = convertApi.createParams()
params.add('file', elFileInput.files[0])
let result = await convertApi.convert('docx', 'pdf', params)

// Get result file URL
let url = result.files[0].Url

Convert remote file

let params = convertApi.createParams()
params.add('file', new URL(''))
let result = await convertApi.convert('pptx', 'pdf', params)

// Get result file URL
let url = result.files[0].Url

Additional conversion parameters

ConvertAPI accepts extra conversion parameters depending on converted formats. All conversion parameters and explanations can be found here.

// Converting PDF to JPG file
let params = convertApi.createParams()
params.add('file', e.currentTarget.files[0])
params.add('ScaleImage', 'true')
params.add('ScaleProportions', 'true')
params.add('ImageHeight', '300')
params.add('ImageWidth', '300')
let result = await convertApi.convert('pdf', 'jpg', params)

// Get result file URL
let url = result.files[0].Url

More examples

You can find more advanced examples in the examples folder.

Converting your first file, full example:

ConvertAPI is designed to make converting file super easy, the following snippet shows how easy it is to get started. Let's convert WORD DOCX file to PDF:

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <title>Conversion Example</title>
    <script src=""></script>
    <h1>ConvertAPI JavaScript library example</h1>
    <h2>Conversion Example</h2>
        <label for="fileInput">Select DOCX file to convert it to PDF</label>
        <input id="fileInput" type="file" accept="application/vnd.openxmlformats-officedocument.wordprocessingml.document">
    <p id="result">
        Result file:
        <a id="resultLink" href=""></a>
    <script src="index.js"></script>
let convertApi = ConvertApi.auth({secret: '<YOUR_SECRET>'})
let elResult = document.getElementById('result')
let elResultLink = document.getElementById('resultLink') = 'none'

// On file input change, start conversion
document.getElementById('fileInput').addEventListener('change', async e => { = 'none' = 'wait'
    try {

        // Converting DOCX to PDF file
        let params = convertApi.createParams()
        params.add('file', e.currentTarget.files[0])
        let result = await convertApi.convert('docx', 'pdf', params)

        // Showing link with the result file
        elResultLink.setAttribute('href', result.files[0].Url)
        elResultLink.innerText = result.files[0].Url = 'block'

    } finally { = 'default'

This is the bare-minimum to convert a file using the ConvertAPI client, but you can do a great deal more with the ConvertAPI JS library. Take special note that you should replace <YOUR_SECRET> with the secret you obtained in item two of the pre-requisites.

Issues & Comments

Please leave all comments, bugs, requests, and issues on the Issues page. We'll respond to your request ASAP!


The ConvertAPI JS Library is licensed under the MIT license. Refere to the LICENSE file for more information.