Most phone photos carry an EXIF block: camera model, date and time, and often the exact GPS coordinates where the photo was taken. Big platforms usually strip it on upload. Your own app, a small forum, a file-sharing link or an email attachment often won't.
If your app accepts user photos, removing that metadata before the file leaves the user's device is a cheap privacy win. Here are two ways to do it in plain browser JavaScript.
Option 1: Re-encode through a canvas (any format, simplest)
When you draw an image onto a canvas and export it, the browser writes a brand-new file. None of the original metadata comes along.
async function stripByReencode(file, quality = 0.92) { const bitmap = await createImageBitmap(file); // applies EXIF rotation in modern browsers const canvas = document.createElement('canvas'); canvas.width = bitmap.width; canvas.height = bitmap.height; canvas.getContext('2d').drawImage(bitmap, 0, 0); const type = file.type === 'image/png' ? 'image/png' : 'image/jpeg'; return new Promise((resolve) => canvas.toBlob(resolve, type, quality)); } Trade-off: JPEGs get compressed a second time, so you lose a little quality, and the file size changes. Colour profiles are also dropped, which can shift colours slightly on wide-gamut photos.
Option 2: Remove the EXIF segment from a JPEG (lossless)
A JPEG is a list of segments. Each starts with 0xFF plus a marker byte, then a 2-byte length. EXIF (and XMP) live in the APP1 segment, marker 0xE1. If we copy every segment except APP1, the image data is untouched.
async function stripJpegExif(file) { const buf = new Uint8Array(await file.arrayBuffer()); if (buf[0] !== 0xff || buf[1] !== 0xd8) throw new Error('Not a JPEG'); const parts = [buf.subarray(0, 2)]; // SOI marker let i = 2; while (i < buf.length) { if (buf[i] !== 0xff) throw new Error('Unexpected data at ' + i); const marker = buf[i + 1]; // Start of Scan: everything after this is compressed image data if (marker === 0xda) { parts.push(buf.subarray(i)); break; } const length = (buf[i + 2] << 8) | buf[i + 3]; const segment = buf.subarray(i, i + 2 + length); // Drop APP1 (EXIF / XMP); keep everything else if (marker !== 0xe1) parts.push(segment); i += 2 + length; } return new Blob(parts, { type: 'image/jpeg' }); } Gotcha: orientation. The EXIF block also stores which way is up. Phones often save the pixels sideways and set an orientation flag. Remove the flag and some viewers show the photo rotated. If that matters, either rotate the pixels first (Option 1 does this for you) or keep the orientation and only drop the GPS tags, which needs a proper EXIF parser.
Wire it into an upload
input.addEventListener('change', async () => { const file = input.files[0]; const clean = file.type === 'image/jpeg' ? await stripJpegExif(file) : await stripByReencode(file); const form = new FormData(); form.append('photo', clean, file.name); await fetch('/upload', { method: 'POST', body: form }); }); Still strip metadata on the server too. Client-side stripping protects users of your UI, but anyone can call your API directly.
How to check it worked
Open the result in any EXIF viewer and look for the GPS fields. On the command line, exiftool photo.jpg | grep -i gps should print nothing.
If you want to do this without code, we made a free Remove Metadata tool on PixelKaro that strips EXIF and GPS in the browser (the photo is never uploaded), and a metadata viewer on the same site to see what a photo carries before you share it.
Did you know your photos carried location data? Most people I show this to don't.
![UI Practice - Duolingo [1]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8uawvr6a0e07ilktpkk7.png)

