Figma SVG exports are a mess, any cleaner way?

jen_93

Member
Messages
62
Reaction score
0
Location
Cape Town, ZA

I've been working on a set of 80 custom icons for a web app, and Figma's SVG export is driving me nuts. Every single icon comes out with nested <g> tags, inline styles, and sometimes a <rect> that covers the whole artboard. The file sizes are absurd for what should be simple paths. I tried running them through SVGO with a bunch of plugins, but it broke some gradients and clip paths, so I ended up manually cleaning each one in a text editor. Took hours.

I've tried the "Presentation attributes" export setting, and I've outlined all strokes, but it still adds extra groups. Illustrator's SVG export isn't much better, though at least it has more options for decimal precision and such. I know some bloat is fine if you're using a build step, but I'm inlining these as React components, so every extra byte counts. And it makes the code harder to read when I need to tweak something.

There has to be a better workflow. I've heard of plugins like "SVG Export" or "Figma to SVG" but I'm not sure which ones actually do a good job. Has anyone found a reliable way to get clean SVGs out of Figma? Or do you just accept the cruft and move on? I'm on a deadline here, so any tips would be appreciated.

greg_ohio

New Member
Messages
71
Reaction score
0
Location
Columbus, OH

Bhai ye Figma export ka dukh main bhi jhela hai 😅 I was building a small landing page for my slots thing and needed maybe 12 icons, nothing crazy. Figma ne aise files diye ki ek khol ke notepad mein, phir turant band kar diya. G tags ke andar g tags, aur wo full artboard wala rect bhi. I wasted a full evening on that rect thinking it was part of the logo, only to realise it wasn't even visible.

What worked for me (kind of) was svgomg with only 2-3 plugins on, like cleanupIds and removeDimensions. Jaise hi maine sab plugins enable kiye, mera gradient gaya aur ek clip path bhi tut gaya. So less is more, I guess.

Question though, you said you're inlining these as React components. Can't you just keep them as .svg files and import them normally? Or does your setup not allow that? Asking because I'm a total noob here and maybe I'm doing it the dumb way, but 80 icons sounds like a lot to hand-clean in a text editor on a deadline 😬

You must log in or register to reply here.