Design · verktøy

SVG-optimaliserer

Lim inn eller velg en SVG for å lage en optimalisert kopi.

Kjøres i nettleseren. Ingen opplasting.

Values are processed locally in this browser.

Result

—

Om verktøyet

SVG-optimaliserer sem complicação.

Den lokale optimalisereren avviser skript, eksternt innhold og eksterne referanser i stedet for å forsøke å gjøre aktiv SVG sikker. Se gjennom resultatet før publisering.

Veiledning

Slik bruker du SVG-optimaliserer

The SVG Optimizer makes a smaller copy of an SVG file by taking out comments and extra white space. You paste the markup or choose a file, and you get cleaned text plus a download. It does not redraw, merge or round any shapes, and it refuses SVGs that contain scripts or links to other sites.

Slik gjør du

  1. Paste the full SVG markup into the box, or choose an SVG file. The text must start with the svg tag, with an optional XML line before it.
  2. Press the button to run the cleanup. If the file has active or external content, the tool stops and shows a message instead.
  3. Read the optimized text and compare it with your original. Then download it as usefulverse-optimized.svg.

Eksempler

Removing a comment and spaces

Du skriver inn
SVG
<svg width="10" height="10"> <!-- background --> <rect width="10" height="10" fill="#fff" /> </svg>
Du får
SVG
<svg><text xml:space="preserve">a b</text></svg>
Tegn før
109
Tegn etter
76

The comment goes, line breaks and spaces between tags go, double spaces inside tags shrink to one, and the space before a closing slash goes too. The shapes are untouched.

Kjørt med verktøyets egen kode.

A script is rejected

Du skriver inn
SVG
<svg><script>alert(1)</script></svg>
Du får
Melding
This SVG contains active or external content and was not processed.

Script tags, event attributes such as onload, links to outside addresses and foreignObject make the tool stop. It does not try to clean them, so nothing is returned.

Kjørt med verktøyets egen kode.

A caution about preserved spaces

Du skriver inn
SVG
<svg><text xml:space="preserve">a b</text></svg>
Du får
SVG
<svg><text xml:space="preserve">a b</text></svg>

The tool collapses runs of spaces everywhere, also inside text. If a file relies on spaces that were meant to stay, the optimized copy can look different. Compare before you use it.

Kjørt med verktøyets egen kode.

Når det er nyttig

  • Trim comments and indentation from an SVG icon before adding it to a web page.
  • Make inline SVG in HTML a little shorter.
  • Check quickly whether an SVG holds scripts or outside links.

Begrensninger

  • It only removes comments and extra white space. It does not merge paths, shorten numbers, remove unused ids or compress like a full optimizer, so the savings are small.
  • Input must be a complete SVG document. Anything else, such as HTML or a fragment, returns the message to paste a complete SVG document.
  • The safety check is a simple text match. It may also reject harmless text that looks like an attribute, such as a word starting with on followed by an equals sign, so review any file it blocks.

Tips

  • Keep your original file and compare the result in a browser before you replace it.
  • Avoid xml:space preserve text if you plan to optimize, or check that text by eye afterwards.
  • Gzip on your server will usually shrink SVG much more than this tool, so use both.

Vanlige spørsmål

Sobre SVG-optimaliserer.

What does the SVG Optimizer remove?

It removes comments, line breaks and tabs, extra spaces, spaces between tags and the space before a closing bracket. The drawing instructions and values are left as written.

Will my SVG look the same afterwards?

Usually yes, because only comments and white space change. The exception is text that depends on exact spacing, so open both files side by side before you replace the original.

Why was my SVG not processed?

The tool refuses SVGs with script tags, on-event attributes, links starting with http, https or two slashes, javascript links or foreignObject. Such files can be unsafe, so it stops instead of trying to repair them.

Does it work with a file as well as pasted text?

Yes. A chosen file is read only when the text box is empty. If the box already holds text, that text is used and the file is ignored, so clear the box first.

Is my SVG uploaded to a server?

No. The cleanup runs inside your browser on the text you give it. The file you download is made on your device, so nothing is sent away.

How much smaller will my file be?

It depends on the file. A hand-written SVG full of comments and indentation can shrink a lot, while a file from a design tool often shrinks only a little, as most of its size is path data.

Hvordan bruker du SVG-optimaliserer?

Lim inn eller velg en SVG for å lage en optimalisert kopi.

Lastes dataene mine opp til en server?

Nei. Behandlingen skjer i nettleseren din, og opplysningene dine lastes ikke opp.