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 token at https://www.convertapi.com/a/authentication
If you are interested in our old version of non-module JavaScript library you can find it here.
To load it with a script tag, pin its version: <script src="https://unpkg.com/convertapi-js@1.0.8/lib/convertapi.js"></script>.
You can try this library on CodeSandbox
- Simple Conversion
- Conversion with additional parameters
- Conversion Chaining
- Web Page Conversion
- Convert HTML string to PDF
- Online PDF converter
- All examples
Run this line from console:
npm i convertapi-js@~1.1You can get your token at https://www.convertapi.com/a/authentication
import ConvertApi from 'convertapi-js'
let convertApi = ConvertApi.auth('api-token')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].Urllet params = convertApi.createParams()
params.add('file', new URL('https://cdn.convertapi.com/cara/testfiles/presentation.pptx'))
let result = await convertApi.convert('pptx', 'pdf', params)
// Get result file URL
let url = result.files[0].UrlConvertAPI 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', elFileInput.files[0])
params.add('ImageHeight', '300')
params.add('ImageWidth', '300')
params.add('FitToSize', 'true')
let result = await convertApi.convert('pdf', 'jpg', params)
// Get result file URL
let url = result.files[0].UrlTo use a regional server, pass its host name as the second argument of ConvertApi.auth, without https:// or a trailing slash. The default is v2.convertapi.com; the regional hosts are listed on the server locations page.
let convertApi = ConvertApi.auth('api-token', 'eu-v2.convertapi.com')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. Refer to the LICENSE file for more information.