o rects aren’t the culprit. Next most common offenders:

A white fill on the <svg> root (background applied at root).

A white-filled <path> acting as a background rectangle (often something like M0 0 H{W} V{H} … Z).

An embedded raster <image> (PNG/JPG) with a baked white background.

A CSS rule in <style> setting background or fill:white globally.

Run these quick console checks right after you generate:

A) One-liners to identify the culprit
// 1) Grab the current SVG string your app previewed
window.__svg = window.previewSvg || window.aiPreviewSvg || window.generatedSvg || "";

// 2) Root background/fill?
console.log("[svg-check] svg@style:", (window.__svg.match(/<svg[^>]*style="([^"]*)"/i)||[])[1]);
console.log("[svg-check] svg@fill :", (window.__svg.match(/<svg[^>]*\sfill="([^"]*)"/i)||[])[1]);

// 3) Any <style> with background or white fill?
console.log("[svg-check] has style background:", /<style[^>]*>[\s\S]*background[^<]*<\/style>/i.test(window.__svg));
console.log("[svg-check] has style white fill:", /<style[^>]*>[\s\S]*fill\s*:\s*(#fff|#ffffff|white)/i.test(window.__svg));

// 4) Any embedded raster?
console.log("[svg-check] embedded raster <image>:", /<image[^>]+href=.+data:image\//i.test(window.__svg));

// 5) White-filled paths/polys (dump first few)
(() => {
  const doc = new DOMParser().parseFromString(window.__svg, "image/svg+xml");
  const whites = [...doc.querySelectorAll("path[fill], polygon[fill], circle[fill], ellipse[fill]")]
    .filter(n => /^(#fff(?:fff)?|white|rgb\( ?255 ?, ?255 ?, ?255 ?\)|rgba\( ?255 ?, ?255 ?, ?255 ?, ?1 ?\))$/i.test((n.getAttribute("fill")||"").trim()));
  console.log(`[svg-check] white-filled shapes: ${whites.length}`);
  whites.slice(0,5).forEach((n,i)=>console.log(`[svg-check] #${i}`, n.tagName, n.getAttribute("fill"), (n.getAttribute("d")||"").slice(0,120)));
})();


Reply back with those [svg-check] … lines and we’ll know exactly which path to kill.

If you want Replit to harden the sanitizer now (tiny rules)

Ask them to add these extra removals to svg-sanitize.ts (in addition to rects):

Root background/fill

Strip background* from <style> blocks.

On <svg> root: remove fill="white|#fff" and style="…background:…"; force style.background = 'none'.

White-filled shapes that act as backgrounds

Remove any <path|polygon> with white fill and:

it’s the first child of <svg> or a top-level <g id*="background">, and

its d looks like a rectangle covering the artboard (e.g., contains M0 0 and either H{viewBoxWidth}/V{viewBoxHeight} or Z with axis-aligned bounds).
(Heuristic: /M0[, ]0/i and H\s*{W} and/or V\s*{H})

Embedded raster images

If any <image> exists and you want pure vectors, remove them (or warn).

That’ll make white backgrounds basically impossible to slip through.