# SVG optimizer

Shrink an SVG file by removing comments, editor data, metadata and spare white space, and rounding long decimals.

Removes what a browser never draws: comments, the XML declaration and doctype, metadata blocks, Inkscape, Sodipodi, Sketch, Figma and Illustrator editor data, empty groups, and white space between elements. Long decimal numbers in coordinates are rounded. Text, styles, ids, transforms and the viewBox are left exactly as they are, so the drawing looks the same.

- Endpoint: `POST https://setget.net/v1/tools/svg-optimize` with JSON `{"input": {...}}` (add `"wait": 30` to hold the reply until the job finishes)
- MCP: `run_tool` with `slug` = `svg-optimize`
- Page: https://setget.net/tools/svg-optimize

## Files in, files out

This is a file tool. Its file inputs take file references, not file contents and not web addresses.

- Get a reference by uploading: `curl -T FILE https://setget.net/drop/` prints a line `ref  <id>/f1`. Or `POST https://setget.net/v1/drops` with `{"files":[{"name","size"}]}`, PUT the bytes to the returned `upload.url` with the listed headers, and use the file's `ref`. Over MCP use the `drop` tool. A file under about 700 KB can also be sent in place as a `data:<type>;base64,<content>` URI.
- Uploads are at most 100 MB per file, are readable by anyone with the link, and expire (one hour by default). Programs are refused.
- The tool runs as a job. The reply is `{"tool", "ms", "result", "files", "job"}`: `result` is JSON, and every result file comes back in `files` as `{"name", "size", "content_type", "kind", "url", "ref"}`. Download it from `url`, or pass `ref` as the input of another file tool.
- A job still running when the wait ends answers 202 with `job`. Follow it with `GET https://setget.net/v1/jobs/<id>?wait=30`, or stream progress from `GET https://setget.net/v1/jobs/<id>/events` (over MCP: the `job` tool). A person can watch it at `job.url`.

## Inputs

- `svg` (required, file, a file reference such as `DROP_ID/f1`, accepts image, text): The SVG file to shrink.
- `precision` (optional, integer, default `3`, range 1..8): Decimal places kept in coordinates and sizes. Numbers below 1 keep this many significant digits instead.
- `strip_scripts` (optional, boolean, default `false`): Also remove scripts, event handlers such as onclick, and javascript: links.

## Example 1: Clean up an SVG

Upload first. Each placeholder below stands for the reference of one upload: `DROP_ID/f1` = [sample.svg](https://setget.net/static/samples/sample.svg).

```json
{"input":{"svg":"DROP_ID/f1"},"wait":30}
```

## Example 2: One decimal place, scripts removed

Upload first. Each placeholder below stands for the reference of one upload: `DROP_ID/f1` = [sample.svg](https://setget.net/static/samples/sample.svg).

```json
{"input":{"svg":"DROP_ID/f1","precision":1,"strip_scripts":true},"wait":30}
```

**Will my drawing look different?** It should not. Only things with no effect on the picture are removed. Rounding moves points by less than a thousandth of a unit at the default precision; raise "precision" for drawings with a very small viewBox, or if you see any change.

**Can I still edit the file in Inkscape or Illustrator?** Yes, it stays a normal SVG. Editor-only extras such as guides, grid settings and layer names are removed, so keep your original for editing.

**What happens to scripts?** They are kept unless you set strip_scripts. The result always tells you how many scripts and event handlers the file holds, which is worth checking for files from other people.

**Why was my file refused for "entities"?** Files that define their own entities (<!ENTITY ...>) can be built to overload the program reading them, so they are not processed. Illustrator writes these when "Preserve Illustrator Editing Capabilities" is ticked: export again without it.

**What is not done?** Ids are not renamed, shapes are not merged and styles are not rewritten. Those save more but can change how a drawing behaves on a page.
