Instagram, Facebook and Threads add an "AI info" label. TikTok says "AI-generated", Pinterest says "AI modified", X says "Made with AI". In most cases these platforms are not analysing pixels. They read metadata inside the file.
That is why a real photo with one Generative Fill edit gets labelled, and why people search for an AI label remover or an AI image label remover. In this post we build the core of one in plain JavaScript. It runs fully in the browser, so the image is never uploaded.
| Signal | Where it lives |
|---|---|
| C2PA Content Credentials | JPEG APP11 (JUMBF boxes), PNG caBX chunk |
IPTC DigitalSourceType ( trainedAlgorithmicMedia ) |
XMP packet |
| XMP edit history, tool names | JPEG APP1 (XMP) |
| Exif (camera, GPS, serials, thumbnail) | JPEG APP1 (Exif), PNG eXIf |
| Prompts (Stable Diffusion, ComfyUI) | PNG tEXt /iTXt /zTXt |
We keep the ICC colour profile (JPEG APP2, PNG iCCP), otherwise colours shift.
async function readFile(file) {
return new Uint8Array(await file.arrayBuffer());
}
A JPEG is a sequence of segments: 0xFF, a marker byte, a 2-byte big-endian length, then the payload. Image data starts at Start of Scan (0xFFDA), and we copy everything from there unchanged.
function cleanJpeg(buf) {
if (buf[0] !== 0xff || buf[1] !== 0xd8) throw new Error('Not a JPEG');
const out = [buf.subarray(0, 2)];
let i = 2;
while (i < buf.length) {
if (buf[i] !== 0xff) throw new Error('Bad marker');
const marker = buf[i + 1];
if (marker === 0xda) { out.push(buf.subarray(i)); break; } // SOS
const len = (buf[i + 2] << 8) | buf[i + 3];
const seg = buf.subarray(i, i + 2 + len);
const drop =
marker === 0xe1 || // APP1: Exif / XMP
marker === 0xeb || // APP11: C2PA / JUMBF
marker === 0xed || // APP13: Photoshop IPTC
marker === 0xfe; // COM: comments
if (!drop) out.push(seg); // keeps APP2 (ICC), DQT, SOF, DHT...
i += 2 + len;
}
return concat(out);
}
After the 8-byte signature, a PNG is a list of chunks: length (4 bytes), type (4 ASCII bytes), data, CRC.
const DROP = new Set(['tEXt', 'iTXt', 'zTXt', 'eXIf', 'caBX', 'tIME']);
function cleanPng(buf) {
const view = new DataView(buf.buffer, buf.byteOffset);
const out = [buf.subarray(0, 8)];
let i = 8;
while (i < buf.length) {
const len = view.getUint32(i);
const type = String.fromCharCode(...buf.subarray(i + 4, i + 8));
const end = i + 12 + len;
if (!DROP.has(type)) out.push(buf.subarray(i, end));
i = end;
if (type === 'IEND') break;
}
return concat(out);
}
js
function concat(parts) {
const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
let o = 0;
for (const p of parts) { out.set(p, o); o += p.length; }
return out;
}
function stillHasAiTags(buf) {
const text = new TextDecoder('latin1').decode(buf);
return /c2pa|jumb|trainedAlgorithmicMedia|parameters|Firefly/i.test(text);
}
function download(buf, name, type) {
const url = URL.createObjectURL(new Blob([buf], { type }));
Object.assign(document.createElement('a'), { href: url, download: name }).click();
URL.revokeObjectURL(url);
}
Because we never decode the image, the output has the exact same pixels and no quality loss.
If you just want the finished tool, AI Flag Remover is a free AI label remover built this way, with HEIC/WebP/AVIF support, batch mode and a "keep camera data" option. Disclosure: I build it.
Only for metadata-based detection. A metadata cleaner does not touch invisible pixel watermarks such as Google's SynthID, and it does not change how pixel-based AI detectors judge an image. It also cannot change a label on a post that is already live.
The honest use case is fixing false AI labels on real photos and removing private data such as GPS. If an image is AI-generated, disclose it: platforms and laws like the EU AI Act increasingly require that.