✂️ SVG 优化SVG Optimizer
在本地优化 SVG:默认先清理脚本等危险内容,再去掉注释、元数据、编辑器信息、空分组和多余小数,并用渲染对比确认外观不变。Optimise SVG locally: by default it first removes scripts and other unsafe content, then strips comments, metadata, editor data, empty groups and extra decimals, and checks by rendering that the result looks the same.
使用说明与常见问题How-to & FAQ
「SVG 优化」是什么?What is the SVG Optimizer tool?
在本地优化 SVG:默认先清理脚本等危险内容,再去掉注释、元数据、编辑器信息、空分组和多余小数,并用渲染对比确认外观不变。Optimise SVG locally: by default it first removes scripts and other unsafe content, then strips comments, metadata, editor data, empty groups and extra decimals, and checks by rendering that the result looks the same.
如何使用「SVG 优化」?How do I use the SVG Optimizer tool?
在「SVG 优化」中,按需设置「小数位」等选项,然后点击「优化」、「复制」、「下载 SVG」按钮即可。In the SVG Optimizer: Set "Decimals", then click "Optimize", "Copy", "Download SVG".
改了设置或内容要重新点优化吗?Do I need to click Optimize again after an edit?
不用。修改 SVG 内容、小数位或任一选项后会自动重新优化(约 0.4 秒后);刚改完马上点下载或复制,也会先按新设置重新优化,所以拿到的总是当前设置的结果。No. Editing the SVG, the decimals or any option re-optimises automatically (after about 0.4 s), and clicking Download or Copy straight after an edit re-optimises with the new settings first, so you always get the result for the current settings.
做了哪些优化?What does it optimise?
删除注释、metadata 元素、Inkscape / Sodipodi / Illustrator / Sketch 等编辑器的元素和属性、空的 g 分组、空属性和取默认值的 opacity 类属性;把几何属性(d、points、坐标、尺寸、transform 等)里的小数按「小数位」四舍五入;去掉标签之间的空白,但 text、style 元素和 xml:space="preserve" 里的空白保留。It removes comments, metadata elements, Inkscape / Sodipodi / Illustrator / Sketch editor elements and attributes, empty g groups, empty attributes and opacity-style attributes set to their default; rounds decimals in geometry attributes (d, points, coordinates, sizes, transform…) to the chosen Decimals; and removes whitespace between tags while keeping it inside text and style elements and xml:space="preserve".
会清理恶意内容吗?Does it remove malicious content?
默认勾选「清理脚本等危险内容」:删除 script、foreignObject、iframe/object/embed、所有 on* 事件属性、javascript: 链接和非图片的 data: 链接。取消勾选则保留这些内容(不推荐用于来路不明的 SVG)。Sanitise is on by default: it deletes script and foreignObject elements, iframe/object/embed, every on* event attribute, javascript: links and non-image data: links. Untick it to keep them (not recommended for SVGs from unknown sources).
怎么确认外观没变?How do I know it looks the same?
优化后会把原图和结果各渲染成 160×160 像素比较;一致时显示「渲染对比一致」,有差异会提示差异像素数,可增加小数位或选「不改」。After optimising, the original and the result are both rendered at 160×160 px and compared. You'll see "renders the same", or the number of differing pixels — then raise Decimals or pick Keep.
有哪些选项可以调整?What options can I adjust?
「SVG 优化」的设置:「小数位」可选 3、2、1、4、6、不改(默认 3);可勾选:「清理脚本等危险内容」(默认勾选)、「去掉元数据和编辑器信息」(默认勾选)。每次生成结果都按当前设置处理。Settings in the SVG Optimizer — "Decimals": 3, 2, 1, 4, 6, Keep (default 3); tick boxes: "Sanitise (remove scripts and unsafe content)" (on by default), "Remove metadata and editor data" (on by default). The result always uses the current settings.
「SVG 优化」免费吗?需要注册吗?Is the SVG Optimizer free? Do I need an account?
「SVG 优化」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The SVG Optimizer is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.