
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
heic-convert
Advanced tools
Convert HEIC/HEIF images to JPEG and PNG
npm install heic-convert
Convert the main image in a HEIC to JPEG
const { promisify } = require('util');
const fs = require('fs');
const convert = require('heic-convert');
(async () => {
const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic');
const outputBuffer = await convert({
buffer: inputBuffer, // the HEIC file buffer
format: 'JPEG', // output format
quality: 1 // the jpeg compression quality, between 0 and 1
});
await promisify(fs.writeFile)('./result.jpg', outputBuffer);
})();
Convert the main image in a HEIC to PNG
const { promisify } = require('util');
const fs = require('fs');
const convert = require('heic-convert');
(async () => {
const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic');
const outputBuffer = await convert({
buffer: inputBuffer, // the HEIC file buffer
format: 'PNG' // output format
});
await promisify(fs.writeFile)('./result.png', outputBuffer);
})();
Convert all images in a HEIC
const { promisify } = require('util');
const fs = require('fs');
const convert = require('heic-convert');
(async () => {
const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic');
const images = await convert.all({
buffer: inputBuffer, // the HEIC file buffer
format: 'JPEG' // output format
});
for (let idx in images) {
const image = images[idx];
const outputBuffer = await image.convert();
await promisify(fs.writeFile)(`./result-${idx}.jpg`, outputBuffer);
}
})();
The work to convert an image is done when calling image.convert(), so if you only need one of the images in a multi-image file, you can convert just that one from the images array and skip doing any work for the remaining images.
Note that while the converter returns a Promise and is overall asynchronous, a lot of work is still done synchronously, so you should consider using a worker thread in order to not block the main thread in highly concurrent production environments.
While the NodeJS version of heic-convert may be compiled for use in the browser with something like webpack, not all build tools necessarily like to compile all modules well. However, what further complicates things is that this module uses pure-javascript implementations of a jpeg and png encoder. But the browser has its own native encoders! Let's just use those instead of including a ton of extra code in your bundle.
When compiling a client-side project, use:
const convert = require('heic-convert/browser');
This is currently only supported in the main thread. Support for workers may be added in the future, but if you need it sooner, please create an issue or even a PR!
heic2any is a JavaScript library that converts HEIC images to other formats like JPEG, PNG, and WebP. It is similar to heic-convert in that it provides conversion capabilities, but it is often used in browser environments, whereas heic-convert is more commonly used in Node.js environments.
Sharp is a high-performance image processing library for Node.js that supports conversion from HEIC to other formats among many other image processing tasks. While sharp is more comprehensive and supports a wide range of image manipulations, heic-convert is specifically focused on HEIC conversion.
ImageMagick is a powerful image manipulation tool that can be used via command line or through Node.js bindings. It supports HEIC conversion among many other features. Compared to heic-convert, ImageMagick is more versatile but also more complex to use for simple HEIC conversions.
FAQs
Convert HEIC/HEIF images to JPEG and PNG
The npm package heic-convert receives a total of 375,246 weekly downloads. As such, heic-convert popularity was classified as popular.
We found that heic-convert demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.