Free plan

Optimize SVG

Make an SVG file smaller and safer
POST
/v1/images/svg-optimize

About this tool

An SVG is a picture made of lines and shapes. This tool makes the file smaller by removing everything that is not needed, so it looks the same but loads faster. It also removes anything that could run code, such as scripts. You can choose how many decimals to keep, whether to keep the title text, and whether the result is easy to read or as small as possible. It only works with SVG files.
For example, you shrink a set of website icons so your pages open faster.

How to use it

  1. Choose this tool.
  2. Add your SVG files with Upload or drag and drop.
  3. Leave the settings as they are, or change the precision and what to remove.
  4. Press Generate.
  5. Download the smaller SVG files.

What you get back

You get smaller SVG files that look the same. Download them to replace your originals.
GOOD TO KNOW
The SVG is optimized, never run. One file counts as one image, up to 10 MB.
TEST IT LIVE

Try Optimize SVG in the Studio

One click opens the Studio with this tool already selected. Add your file and see the result in seconds.
Open in the Studio
Family
Images
Plan
Free
Method
POST
Endpoint
/v1/images/svg-optimize
Tool ID
images.svg-optimize
Authentication
API key
Accepts
JPEG, PNG, WEBP, GIF, AVIF, TIFF +15 more
Background jobs
Yes
Usage group
Image
For developers

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/images/svg-optimize" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -F 'images=@photo.jpg' \
  -F 'precision=3' \
  -F 'multipass=true' \
  -F 'response=url'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.images.svgOptimize({
    "images": 'photo.jpg',
    "precision": 3,
    "multipass": true,
    "response": "url"
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->images()->svgOptimize([
    'images' => 'photo.jpg',
    'precision' => 3,
    'multipass' => true,
    'response' => 'url',
]);
echo $result->requestId;
FAQ

Frequently asked questions

Make an SVG file smaller (SVGO) and take out anything that could run code: script elements, on* handlers, javascript: links and foreign objects.

Optimize SVG accepts JPEG, PNG, WEBP, GIF, AVIF, TIFF, SVG, SVGZ, BMP, ICO, APNG, PNM and 9 more. You can send several files in one request.

Optimize SVG is included in every plan, including Free. Each run uses credits from your monthly allowance.

Send a POST request to /v1/images/svg-optimize with your API key in the X-Api-Key header. Official SDKs for Node.js, Python, PHP, Go, Java, .NET and Ruby do the same for you, and the code box on this page shows ready-to-copy examples. For large work it can also run as a background job, so your request returns straight away.