You have an SVG icon and you want to change its color, make it bigger or remove a white background. Opening a full vector editor for this is overkill, and TabShed's in-page SVG editor is not available yet. The good news is that an SVG is just text, and a handful of attributes cover most edits. This guide shows what to change and how to check your work with the tools we do have.
What is inside an SVG
Open an SVG in any text editor and you will see something like this:
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="#ff0000" d="M12 2 L22 22 H2 Z"/></svg>
The root element holds the canvas, and each shape inside it (path, circle, rect, g) holds drawing instructions and style attributes.
The four edits you will make most
| You want to | Edit this |
|---|---|
| Change a color | The fill (inside of a shape) or stroke (outline) value on the shape or on a parent <g> |
| Make it bigger or smaller on a page | The width and height on the root element, or set the size in CSS |
| Crop or add space around the drawing | The four numbers of viewBox="x y width height" |
| Remove a background | Delete the first <rect> that covers the whole canvas |
Colors
A color can appear in several places: as an attribute (fill="#ff0000"), inside a style attribute (style="fill:#ff0000"), or in a <style> block with classes. Search the file for the old color code and replace every occurrence. If you want an icon that takes its color from the surrounding text on a web page, set fill="currentColor" and the icon will follow the CSS color of its parent. To pick the new color, use the Color Picker, which gives you the HEX code, or pull one from a photo using the Image Color Palette tool.
Size and the viewBox
The viewBox is the coordinate system of the drawing, while width and height are the size it is displayed at. As long as the viewBox is there, you can change width and height freely and the drawing scales without distortion, provided the new ratio matches the viewBox ratio. If you delete the viewBox, the drawing cannot scale, and it will be cropped or fixed in size. That is why optimizers keep it.
To add padding, enlarge the viewBox around the drawing. For a drawing that spans 0 0 24 24, a viewBox of -2 -2 28 28 adds a margin of 2 units on every side. To crop, shrink the box and move its origin.
Testing your edit
- Save the file with the .svg extension and open it in a browser tab. If it renders, the syntax is valid. If you see an error about XML, look for a missing quote or an unclosed tag.
- View it at a large and a small size to see whether the edge cuts anything.
- Place it on both light and dark backgrounds if it will be used on both.
What to do afterwards
- Make the file smaller. After hand edits, run it through the SVG Optimizer. It strips leftover metadata and shortens numbers.
- Get a PNG. Use SVG to PNG and choose a 1x, 2x or 4x scale and a transparent or white background. Note that it renders the SVG as an image, so external fonts or linked images inside the SVG are not loaded; convert text to outlines in your design tool first.
- Create an SVG from a bitmap. Use PNG to SVG or JPG to SVG, and then edit the result as described here.
When hand editing is the wrong approach
Redrawing paths, moving individual points, or combining complex shapes is not realistic by hand. Use a vector editor for that, then optimize the exported file. Also be careful with files from untrusted sources: an SVG can contain scripts. The converters on this site render SVGs through an image element, which does not run scripts, but opening an unknown SVG directly in a browser tab may.
Common problems
- The color did not change. There is another definition in a style block or on a parent group. Search the whole file.
- The drawing is cut off after resizing. The new width-to-height ratio differs from the viewBox, or the viewBox is too small.
- A white box shows behind the drawing. Delete the background rect, or set its fill to none.
- The icon looks blurry. A fractional pixel size can blur thin strokes. Use whole numbers for width and height.
A worked example: recolor an icon for dark mode
You have a black icon that must also appear on a dark background. Open the file and search for fill. If the shapes carry fill="#000000", replace it with fill="currentColor" and set the color of the parent element in your CSS. Now the icon follows the text color: dark on light pages and light on dark ones, from a single file. If the icon uses several colors on purpose, leave the colors as they are and make a second file instead. Check both versions in a browser at the sizes you use, and then run them through the SVG Optimizer to remove the leftovers of the edit.
FAQ
Is there an SVG editor on TabShed?
The visual editor page is unfinished and not available. The optimizer and converters work.
Can I edit text in an SVG?
If the text is a <text> element, yes, change its content. If it was converted to outlines, it is just paths.
Which text editor should I use?
Any plain text editor works, as long as it saves plain text with the .svg extension.