WebP Image Conversion Guide
Convert images to WebP format using the Convert Fleet API to reduce file sizes by up to 30% without quality loss. Includes Node.js and Python examples.
You need an API key to follow this guide. Get a free API key →
1Why Convert to WebP?
WebP images are 25–35% smaller than JPEG and PNG at equivalent quality. Google recommends WebP for web performance (Core Web Vitals). Converting your images to WebP can significantly improve page load speed.
2Convert PNG to WebP in Node.js
Use the Convert Fleet API to convert any image to WebP format.
const axios = require('axios');
const fs = require('fs');
const FormData = require('form-data');
async function toWebP(input, output) {
const form = new FormData();
form.append('file', fs.createReadStream(input));
form.append('to', 'webp');
const res = await axios.post('https://convertfleet.com/api/convert', form, {
headers: { ...form.getHeaders(), 'Authorization': 'Bearer YOUR_API_KEY' },
responseType: 'arraybuffer',
});
fs.writeFileSync(output, res.data);
console.log('WebP saved!');
}
toWebP('photo.png', 'photo.webp');That's it!
You've successfully integrated the Convert Fleet API. Check the API reference for the full list of parameters and error codes.
Related API Endpoints
More Integration Guides
Start Building Today
Free tier includes 200 free credits (valid 30 days from signup). Pro plan unlocks unlimited API access.