SVG Optimizer

Runs entirely in your browser

Free online SVG optimizer to clean metadata, compress paths and colors, preserve important elements, preview changes, compare file sizes and download optimized SVG files locally.

Drop an SVG file here, or click to choose
You can also paste SVG source code
SVG only (XML text), up to 2 MB
Parsed in your browser only — nothing is uploaded. 0 B / 2 MB
File — Size — SVG size — Loaded
Optimisation settings Only display-safe options are on by default. If external CSS or scripts rely on element IDs, turn off "Remove unreferenced IDs".
Basic cleanup Recommended defaults; only removes things that never affect rendering
Code compression
Structure
Advanced options
viewBox, accessibility, styles, animation and numeric precision
When off, SVGO may remove viewBox, which changes scaling and responsive behaviour.
Waiting for a file
Result Optimised
Settings changed. Optimise again before downloading or copying the result.
Original size —
Optimised size —
Space saved —
Reduction —
Before / after
Zoom 100%
Original SVG
Original SVG
Optimised SVG
Optimised SVG
The preview strips scripts and external resources. The optimised download also removes active content; the original download is byte-for-byte.
Show SVG source
Privacy Files are parsed and optimised in your browser only. Nothing is uploaded and no network request is made; everything clears when you reload.

Compress SVG Code, Remove Unused Data and Compare File Sizes

Online SVG Optimizer

NZTool SVG Optimizer is a free online SVG compression and code-cleaning tool powered by the SVGO optimization engine. Upload an SVG file or paste SVG source code to remove redundant information, compress path data, simplify color values and reduce file size. After optimization, you can compare the original and optimized graphics, source code and file sizes.

SVG (Scalable Vector Graphics) is an XML-based vector image format widely used for website logos, icons, illustrations, buttons and interface designs. Unoptimized SVG files may contain editor metadata, comments, unnecessary attributes and lengthy path data generated by design software. SVG optimization removes unnecessary code to make vector graphics more compact and easier to load, transfer and maintain in web projects.

Main Features of the SVG Optimizer

  • Remove redundant comments: Remove XML comments from SVG source code to reduce unnecessary text.
  • Clean editor metadata: Remove metadata and redundant information added by design applications.
  • Optimize unnecessary attributes: Clean up redundant, empty and default attributes to reduce repeated code.
  • Compress path data: Optimize SVG path representations to reduce the number of characters used by coordinates and path commands.
  • Optimize color values: Simplify color representations to shorten code while preserving the intended appearance.
  • Clean element IDs: Remove unused element IDs and update related references according to optimization rules. Use this option carefully for SVG files that depend on external CSS or JavaScript.
  • Advanced preservation options: Choose to preserve viewBox, titles, descriptions, CSS styles and animations to reduce the impact of optimization on the original structure.
  • Path precision control: Adjust numeric precision to balance file size and graphic details.
  • Multiple optimization passes: Run multiple optimization passes to attempt further reductions in SVG output size.
  • Before-and-after comparison: View the original and optimized graphics side by side or individually, with background switching and preview zoom.
  • Copy and download: View the original and optimized SVG source code, copy the optimized result or download the file.

How to Use the SVG Optimizer

  1. Import an SVG file: Select a local SVG file or switch to code input mode and paste SVG source code directly.
  2. Choose optimization options: Enable comment removal, metadata cleanup, attribute optimization, path compression, color optimization and ID cleanup as needed.
  3. Configure advanced settings: Choose whether to preserve viewBox, titles, descriptions, styles, animations and XML declarations. Adjust path precision and multiple-pass settings.
  4. Run optimization: Click the optimize button. The tool loads the optimization engine in your browser and processes the SVG content.
  5. Review the results: Check the original file size, optimized file size, saved space and compression ratio. Compare the visual appearance of both versions.
  6. Copy or download: Once the result meets your requirements, copy the optimized SVG code or download the optimized file. You can also download the original file.

SVG Optimization Settings Explained

1. Basic Cleanup Options

Basic cleanup removes redundant information from SVG files that is not required for displaying the final graphic.

  • Remove comments: Remove XML comments to reduce source code length.
  • Clean metadata: Remove editor metadata and related extension information.
  • Optimize attributes: Remove unnecessary attributes and default values to reduce redundant markup.

2. Path and Color Compression

Paths and colors are often important parts of SVG source code. Path optimization simplifies the representation of coordinates and commands, while color optimization converts longer color values into more compact forms. Actual compression results depend on the original SVG structure and graphic complexity.

3. Structural Optimization

SVG elements may use IDs to establish references between gradients, masks, filters and other elements. ID cleanup removes unused identifiers and updates related references according to optimization rules. Use structural optimization carefully with SVG files that depend on external CSS, JavaScript or other external resources, and verify the results in the target environment.

4. Advanced Preservation Settings

  • Preserve viewBox: Retain the SVG coordinate viewport information to help maintain scaling and responsive display.
  • Preserve titles and descriptions: Keep the content of title and desc elements to help assistive technologies and search engines understand the graphic.
  • Preserve CSS styles: Reduce changes to the original style structure for SVG files that depend on class and style attributes. External CSS dependencies still need to be verified in the target environment.
  • Preserve animations: Retain animation-related elements and attributes where possible. Complex SMIL animations, CSS animations and script-driven animations should be tested in the actual usage environment.
  • Preserve XML declaration: Choose whether to retain the XML declaration according to your file usage requirements.
  • Multiple optimization passes: Repeat the optimization process to attempt further file size reductions. Additional passes do not guarantee smaller output every time.
  • Numeric precision: Adjust the decimal precision of path coordinates. Lower precision usually reduces code size, but may cause subtle visual differences in complex graphics.

How to Evaluate SVG Optimization Results

After optimization, the tool displays the original file size, optimized file size, saved space and percentage change. You can compare the original and optimized graphics side by side or switch between individual previews, while also inspecting both SVG source code versions.

A smaller optimized file indicates that the processing reduced the amount of data. If the original SVG has already been professionally optimized or contains little redundant information, the resulting file may remain the same size or even become slightly larger. Check the visual appearance and actual usage results instead of focusing only on the compression ratio.

Common Uses of SVG Optimization

  • Website performance: Compress website logos, icons and decorative SVG graphics to reduce static resource sizes.
  • Frontend development: Clean SVG code exported from design applications to make graphic assets easier to integrate and maintain.
  • UI and web design: Optimize button icons, interface illustrations and other vector assets.
  • Design asset management: Remove editor metadata, comments and redundant attributes from SVG files.
  • Icon library maintenance: Optimize SVG icons across projects to remove unnecessary code.

Privacy and Security

  • SVG files are read and optimized locally in your browser. Original files do not need to be uploaded to a server.
  • The SVGO optimization engine is loaded on demand instead of loading the complete optimization module when the page first opens.
  • Previews use a separate sanitized copy. User-provided SVG source code is not directly inserted into the page HTML.
  • Scripts, event-handler attributes and references that may trigger external network requests are removed during preview processing to reduce risks from untrusted SVG content.
  • The optimized output undergoes XML validity checks. Invalid optimized files are not offered for download.
  • Script elements are removed during optimization to reduce the security risks of SVG script execution. Interactive SVG files that depend on scripts may lose their original interactive functionality.
  • Preview sanitization and actual optimization output are separate processes. Review the optimized SVG source code and visual appearance before downloading and using it.

Frequently Asked Questions

SVG optimization removes redundant comments, metadata and unnecessary attributes from SVG source code, while compressing path data and simplifying color values to reduce file size while preserving the original graphic's appearance as much as possible.

Upload an SVG file or paste SVG source code, select the cleanup and compression options you need, and click the optimize button. You can then review file size changes, preview the graphic, copy the code or download the optimized SVG file.

Normal SVG optimization attempts to preserve the original appearance, but path precision adjustments, style changes and structural cleanup may affect some complex graphics. Compare the original and optimized previews, and preserve viewBox, styles, titles, descriptions and animations when necessary.

If the original SVG has already been compressed or has a simple structure, there may be little redundant information to remove. Some optimization transformations may also add a small amount of text, so the optimized file is not always smaller.

The corresponding advanced preservation options are available. You can choose to preserve CSS styles and SVG animations while reducing changes to related structures. However, external CSS, complex SMIL animations, CSS animations and script-driven animations may still be affected. Test the downloaded file in its actual usage environment.

The viewBox defines the SVG's internal coordinate system and visible area. It is important for vector scaling and responsive display. Removing viewBox may affect how the graphic appears in containers of different sizes, so preserving it by default is recommended.

No. According to the tool's local processing design, SVG file reading, parsing, optimization and previewing are performed in your browser. The original SVG file does not need to be sent to a server.

This tool uses SVGO 3.3.2 for SVG optimization. SVGO is an optimization tool designed to clean and compress SVG files. Its plugin configuration can control comment removal, path optimization, color conversion and structural processing.

What Is an SVG Optimizer?

An SVG optimizer is an online tool for cleaning and compressing SVG (Scalable Vector Graphics) code. It removes comments, editor metadata and redundant attributes, optimizes path data and color values, and reduces file size while preserving the graphic's appearance and important structures as much as possible. It is suitable for website logos, icons, illustrations and vector assets used in frontend projects.
  • Remove SVG comments, editor metadata and redundant attributes to simplify source code
  • Compress SVG path data and optimize color values to reduce file size
  • Clean unused IDs and redundant structures, with adjustable path precision
  • Optionally preserve viewBox, titles, descriptions, CSS styles and animations
  • Upload SVG files or paste source code to compare graphics and file sizes before and after optimization
  • Copy optimized SVG code or download the optimized file
Upload an SVG file or paste its source code, select the optimization options you need, and adjust path precision and content preservation settings to review the optimized result, graphic preview and file size changes. All processing takes place locally in your browser without uploading files. For SVG files containing complex styles, fonts, filters or animations, check the results in the target environment.
Comments 0
No comments yet. Be the first to comment!
avatar
Comment content cannot be empty
0/255