cd /news/artificial-intelligence/build-an-ai-label-remover-in-the-bro… · home › topics › artificial-intelligence › article
[ARTICLE · art-173960] src=dev.to ↗ pub= topic=artificial-intelligence verified=true sentiment=· neutral

Build an AI Label Remover in the Browser: Strip C2PA, IPTC and XMP From Images With JavaScript

A developer published a browser-based JavaScript tool that strips C2PA Content Credentials, IPTC DigitalSourceType, XMP edit history, Exif and embedded prompts from JPEG and PNG files by parsing segment and chunk structures directly, without decoding pixels, so images keep identical quality. The code drops JPEG APP1, APP11, APP13 and COM segments and PNG tEXt, iTXt, zTXt, eXIf, caBX and tIME chunks while preserving the ICC colour profile, and the author frames the honest use case as correcting false AI labels on real photos and removing private data like GPS.

recommendation

When cleaning image metadata, parse JPEG segments and PNG chunks directly and preserve the ICC profile; note this removes only metadata-based labels, not pixel watermarks like SynthID.

more in playbook: Verifying model output
by read3 min views1 publishedNov 21, 2026

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.

── more in #artificial-intelligence 4 stories · sorted by recency
── more on @instagram 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/build-an-ai-label-re…] indexed:0 read:3min 2026-11-21 · —