{"slug": "build-an-ai-label-remover-in-the-browser-strip-c2pa-iptc-and-xmp-from-images", "title": "Build an AI Label Remover in the Browser: Strip C2PA, IPTC and XMP From Images With JavaScript", "summary": "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.", "body_md": "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.\n\nThat 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.\n\n| Signal | Where it lives | \n|---|---|\n| C2PA Content Credentials | JPEG APP11 (JUMBF boxes), PNG `caBX` chunk | \n| IPTC DigitalSourceType ( `trainedAlgorithmicMedia` ) | XMP packet | \n| XMP edit history, tool names | JPEG APP1 (XMP) | \n| Exif (camera, GPS, serials, thumbnail) | JPEG APP1 (Exif), PNG `eXIf` | \n| Prompts (Stable Diffusion, ComfyUI) | PNG `tEXt` /`iTXt` /`zTXt` | \n\nWe keep the ICC colour profile (JPEG APP2, PNG `iCCP`), otherwise colours shift.\n\n```\nasync function readFile(file) {\n  return new Uint8Array(await file.arrayBuffer());\n}\n```\n\nA 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.\n\n```\nfunction cleanJpeg(buf) {\n  if (buf[0] !== 0xff || buf[1] !== 0xd8) throw new Error('Not a JPEG');\n  const out = [buf.subarray(0, 2)];\n  let i = 2;\n  while (i < buf.length) {\n    if (buf[i] !== 0xff) throw new Error('Bad marker');\n    const marker = buf[i + 1];\n    if (marker === 0xda) { out.push(buf.subarray(i)); break; } // SOS\n    const len = (buf[i + 2] << 8) | buf[i + 3];\n    const seg = buf.subarray(i, i + 2 + len);\n    const drop =\n      marker === 0xe1 ||           // APP1: Exif / XMP\n      marker === 0xeb ||           // APP11: C2PA / JUMBF\n      marker === 0xed ||           // APP13: Photoshop IPTC\n      marker === 0xfe;             // COM: comments\n    if (!drop) out.push(seg);      // keeps APP2 (ICC), DQT, SOF, DHT...\n    i += 2 + len;\n  }\n  return concat(out);\n}\n```\n\nAfter the 8-byte signature, a PNG is a list of chunks: length (4 bytes), type (4 ASCII bytes), data, CRC.\n\n``` js\nconst DROP = new Set(['tEXt', 'iTXt', 'zTXt', 'eXIf', 'caBX', 'tIME']);\n\nfunction cleanPng(buf) {\n  const view = new DataView(buf.buffer, buf.byteOffset);\n  const out = [buf.subarray(0, 8)];\n  let i = 8;\n  while (i < buf.length) {\n    const len = view.getUint32(i);\n    const type = String.fromCharCode(...buf.subarray(i + 4, i + 8));\n    const end = i + 12 + len;\n    if (!DROP.has(type)) out.push(buf.subarray(i, end));\n    i = end;\n    if (type === 'IEND') break;\n  }\n  return concat(out);\n}\njs\nfunction concat(parts) {\n  const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));\n  let o = 0;\n  for (const p of parts) { out.set(p, o); o += p.length; }\n  return out;\n}\n\nfunction stillHasAiTags(buf) {\n  const text = new TextDecoder('latin1').decode(buf);\n  return /c2pa|jumb|trainedAlgorithmicMedia|parameters|Firefly/i.test(text);\n}\n\nfunction download(buf, name, type) {\n  const url = URL.createObjectURL(new Blob([buf], { type }));\n  Object.assign(document.createElement('a'), { href: url, download: name }).click();\n  URL.revokeObjectURL(url);\n}\n```\n\nBecause we never decode the image, the output has the exact same pixels and no quality loss.\n\nIf you just want the finished tool, [AI Flag Remover](https://aiflagremover.com/) 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.\n\nOnly 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.\n\nThe 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.", "url": "https://wpnews.pro/news/build-an-ai-label-remover-in-the-browser-strip-c2pa-iptc-and-xmp-from-images", "canonical_source": "https://dev.to/aiflagremover/build-an-ai-label-remover-in-the-browser-strip-c2pa-iptc-and-xmp-from-images-with-javascript-36jn", "published_at": "2026-11-21 22:38:06+00:00", "updated_at": "2026-11-21 22:41:34.880784+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-tools", "developer-tools", "ai-ethics"], "entities": ["Instagram", "Facebook", "Threads", "TikTok", "Pinterest", "X", "Google", "AI Flag Remover"], "also_reported_by": [], "takeaway": "Strip AI provenance metadata by parsing container structures rather than re-encoding: drop JPEG APP1/APP11/APP13/COM segments and PNG tEXt/iTXt/zTXt/eXIf/caBX/tIME chunks while keeping the ICC profile, so pixels and quality are unchanged.", "recommendation": {"advice": "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.", "playbook": "output-verification", "playbook_url": "https://wpnews.pro/playbooks/output-verification"}, "alternates": {"html": "https://wpnews.pro/news/build-an-ai-label-remover-in-the-browser-strip-c2pa-iptc-and-xmp-from-images", "markdown": "https://wpnews.pro/news/build-an-ai-label-remover-in-the-browser-strip-c2pa-iptc-and-xmp-from-images.md", "text": "https://wpnews.pro/news/build-an-ai-label-remover-in-the-browser-strip-c2pa-iptc-and-xmp-from-images.txt", "jsonld": "https://wpnews.pro/news/build-an-ai-label-remover-in-the-browser-strip-c2pa-iptc-and-xmp-from-images.jsonld"}}