If your Node app accepts photo uploads, those photos arrive with GPS positions, phone models, dates and sometimes AI-generation data. The usual advice is "run them through sharp" or "use exif-be-gone". We tested both on the same files: sharp's defaults work but turn phone photos sideways, and exif-be-gone left a WebP's GPS position and camera details completely untouched.

Which Node.js method actually removes EXIF data?

sharp does, if you add one call; exif-be-gone doesn't, for every format. We tested four files: a JPEG stored the way phones store photos (pixels on their side plus an Orientation tag, a Display P3 colour profile, GPS, camera model, date and an XMP author), a Stable Diffusion PNG with its prompt, a WebP with GPS and camera details, and a JPEG with C2PA Content Credentials. We used sharp 0.35 and exif-be-gone 1.5 on Node 23.

Method Metadata gone? Upright? Colour profile JPEG quality
sharp(file).toFile(out) Yes No, sideways Converted to sRGB Re-saved at 80
exif-be-gone No: WebP untouched, C2PA kept No, sideways Kept Untouched
The function below Yes Yes Kept Re-saved at 95
ExifTool from Node (below) Yes Yes Kept Untouched

Does sharp remove EXIF metadata?

sharp removes all metadata by default, which is what you want. The catch is that "all metadata" includes the Orientation tag. Phones don't rotate the pixels of a portrait photo; they store them on their side and add that tag. Remove it without rotating first, and the photo shows up sideways. .rotate() with no angle turns the pixels upright using the tag before it is dropped. In recent versions, .autoOrient() does the same.

Two smaller points:

  • By default sharp converts colours to sRGB and drops the profile. The colours stay right, but a Display P3 photo loses its wider range. .keepIccProfile() keeps the profile, which isn't personal information.
  • sharp saves JPEGs at quality 80 by default. Our test photo came out at a third of its original size. Set the quality yourself.

How to remove EXIF data in Node.js with sharp

import sharp from 'sharp';

export async function removeMetadata(input) {
  const image = sharp(input).rotate().keepIccProfile();   // upright pixels, keep colour profile
  const { format } = await image.metadata();              // 'jpeg', 'png', 'webp'...
  const options = format === 'jpeg' || format === 'webp' ? { quality: 95 } : {};
  return image.toFormat(format, options).toBuffer();
}

On all four test files it removed EXIF, GPS, XMP, the Stable Diffusion prompt and the C2PA data. The photo came out upright with its colour profile. input can be a file path or a Buffer, so it works directly on uploads:

// Express + multer (memoryStorage)
app.post('/upload', upload.single('photo'), async (req, res) => {
  const clean = await removeMetadata(req.file.buffer);
  // save `clean`, never req.file.buffer
});

Don't pass quality for PNG: in sharp it switches PNGs to a reduced colour palette. For animated GIFs and WebPs, sharp reads only the first frame unless you pass { animated: true }.

Does exif-be-gone remove all metadata?

exif-be-gone is a small stream that removes EXIF and XMP segments from JPEGs and PNGs without re-encoding. On our files:

  • the WebP came out byte-for-byte identical, GPS, camera model, date and author included
  • the C2PA Content Credentials stayed in the JPEG
  • the phone photo was sideways, because the Orientation tag went with the EXIF

It's fine for plain JPEGs when you rotate them first. It isn't a general metadata remover.

How to remove EXIF in Node.js without re-encoding

If the pixels must stay exactly the same, don't decode the image. Call ExifTool:

import { execFile } from 'node:child_process';

execFile('exiftool', ['-all=', '--icc_profile:all', '-tagsfromfile', '@', '-Orientation',
                      '-overwrite_original', path], (err) => { if (err) throw err; });

It removes everything, keeps the colour profile, and writes the Orientation tag back so the photo stays upright. On our test photo, the pixels were identical before and after. ExifTool must be installed on the server. The exiftool-vendored npm package bundles it, if you'd rather not install it yourself.

Can sharp handle HEIC photos, videos and PDFs?

  • HEIC (the iPhone default): sharp's prebuilt binaries can't read HEIC photos.
  • Videos, PDFs and RAW files, which users upload too, and which carry the same kind of details.
  • Proof that a file came out clean.

For those, our metadata removal API cleans images, video, PDF and RAW with one call. It checks every result and reports what was removed:

import { readFile, writeFile } from 'node:fs/promises';

const form = new FormData();
form.append('file', new Blob([await readFile('upload.mov')]), 'upload.mov');
const res = await fetch('https://api.aimetadatacleaner.com/v1/clean', {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.AMC_API_KEY}` },
  body: form,
});
const report = await res.json();
if (!res.ok) throw new Error(report.error.message);
console.log(report.status, report.removed);
await writeFile('upload-clean.mov', Buffer.from(await (await fetch(report.download_url)).arrayBuffer()));

The API is part of the Business plan. Cleaning in the browser before upload is covered in stripping EXIF from uploads in JavaScript.

Frequently asked questions

How do I remove EXIF data in Node.js?

Use sharp: sharp(input).rotate().keepIccProfile(), then save in the same format, with quality 95 for JPEG and WebP. sharp removes metadata by default; .rotate() keeps phone photos upright. For lossless removal, call ExifTool instead.

Why are my photos sideways after removing EXIF in Node?

The Orientation tag was removed without rotating the pixels. Add .rotate() (or .autoOrient()) before saving in sharp.

Should I strip EXIF in the browser or on the server?

On the server, always: you can't trust what a client sends. Cleaning in the browser as well protects the user's location before the file leaves their phone.

Why should I remove EXIF data from uploads?

Photos from phones often carry the GPS position where they were taken, which can be someone's home. If your app shows or shares uploaded photos, removing EXIF protects your users, and it also removes the phone model, dates and AI labels.