Home » Developer Tools » SVG Beautifier
Paste messy SVG code and get a clean, readable SVG file in seconds, right in your browser.
Last updated 13 November 2026
Your code never leaves your browser. Everything runs locally on your device.
This tool only formats code. It does not run, compile or execute it, so always review the formatted output before you use it in a project.
SVG code copied from design tools and icon sets is often one long line that is hard to edit. The SVG Beautifier formats your SVG code with clean indentation and clear nesting, so every group, path, and shape is easy to find and change.
This tool is made for SVG vector code specifically: it keeps SVG namespaces, viewBox settings, and CDATA sections intact while it tidies the layout. Everything runs in your browser, so your graphics are never uploaded to a server.
An SVG beautifier takes SVG code that is squeezed onto one long line and lays it out with clean indentation and clear nesting, so you can read it and edit it. Design tools and icon sets often export SVG as a single line to keep the file small, but that makes the code hard to work with when you need to change a color, move a shape, or fix a path. This tool formats the code in your browser with the SVGO pretty print engine, and it changes only spacing and line breaks. Your shapes, colors, and layout stay exactly as they were.
Use it whenever you open an SVG file and cannot tell where one group ends and the next begins. Paste the code, pick an indent size, and copy the tidy result back into your project. When the file is ready to publish, run it through the SVG Minifier to shrink it again for faster loading.
This tool offers two indent sizes, 2 spaces and 4 spaces. Both produce the same structure, so the choice is about how the code reads on your screen and how much the file grows. Here is the same 126 character SVG formatted both ways:
| Indent | Output size | Change |
|---|---|---|
| 2 spaces | 131 characters | 5 characters more, about 4 percent larger |
| 4 spaces | 133 characters | 7 characters more, about 6 percent larger |
Pick 2 spaces for most work: the nesting is still easy to follow, and the file stays smaller. Pick 4 spaces when your SVG has deep nesting, with groups inside groups, because the extra space makes each level stand out more. Either way, the graphic itself looks the same in the browser.
Here is a small SVG run through the tool at the default 2 space indent, with the exact numbers:
Input, 126 characters:
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect x="10" y="10" width="80" height="80" fill="red"/></svg>
Output, 131 characters:
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"> <rect x="10" y="10" width="80" height="80" fill="red"/> </svg>
The output is 131 characters, up from 126. That is 5 characters added, and 5 divided by 126 is 0.0397, so the file is about 4 percent larger. At a 4 space indent the same input becomes 133 characters, about 6 percent larger. The built in sample, 250 characters before formatting, becomes 268 characters after, about 7 percent larger. Beautifying always adds a little size, because readable code needs spaces and line breaks. That is normal, and it is the price of code you can read and edit.
Beautifying only changes the layout of the code, never the graphic it draws. The tool keeps your SVG namespaces, your viewBox setting, and your CDATA sections intact, so embedded content and linked resources keep working. This was checked directly: a test file with a CDATA style block, two namespaces, and a viewBox came through formatting with all three untouched.
Your width and height values, fill colors, paths, groups, and text elements are all left as written. The output draws the same picture as the input, just with the code laid out so you can find each part. If your SVG looks wrong after formatting, the problem was already in the original code, since formatting alone cannot change what the graphic shows.
These two tools do opposite jobs, and you need both at different times. The beautifier adds spaces and line breaks so you can read and edit the code. The minifier strips them out so the file is as small as possible for publishing. Beautify while you work on the file, then minify the finished version before you put it on your site.
Do not use this page for general XML files. It is made for SVG vector graphics, with their groups, paths, shapes, and viewBox settings in mind. For plain XML, use the XML Beautifier instead. And if you work with web pages rather than graphics, the HTML Beautifier formats markup the same way.
Beautify an SVG whenever you need to change it by hand. Common cases are icons downloaded from an icon set, logos exported from a design tool, and inline SVG pasted into a web page. In each case the file arrives as one long line, and formatting it first means you can find the path or group you need in seconds instead of hunting through a wall of code.
It also helps when you are learning SVG. A formatted file shows the nesting clearly: the svg element at the top, groups inside it, and shapes inside each group. You can see at a glance how the picture is built, which makes it much easier to edit with confidence.
Yes, it is completely free with no sign up.
It is made for SVG code. It formats SVG vector graphics with their groups, paths, shapes, and viewBox settings in mind, rather than treating your file as plain XML.
Yes. Beautifying only changes spacing and line breaks. Your graphic keeps the same shapes, colors, and layout.
CDATA sections and namespaces are preserved, so embedded content and linked resources keep working.
No. All beautifying happens in your browser on your own device, so your graphics never leave your computer.
The tool shows a clear error message and keeps your input untouched, so you can fix the problem and try again.
Pick 2 spaces for most work and 4 spaces when your SVG has deep nesting with groups inside groups. The same 126 character sample becomes 131 characters at 2 spaces and 133 characters at 4 spaces, so 4 spaces adds only 2 more characters. The graphic looks the same either way.
Yes, a little. Readable code needs spaces and line breaks, so the file grows. The worked example on this page went from 126 characters to 131 characters, about 4 percent larger, and the built in sample went from 250 characters to 268 characters, about 7 percent larger. Use the SVG Minifier when the file is ready to publish and size matters again.
Yes. Click Choose File and pick any file ending in .svg, or paste the code into the input box. The whole file is formatted at once, and you can download the result as an SVG file. There is no drag and drop on this page, so use the file picker or paste the code.
Yes. The formatted code is still a normal SVG, with its namespaces and viewBox kept intact, so you can paste it straight into your HTML. The tool only formats code and never runs it, so always review the output before you use it in a project.
It shows how much the file size changed after formatting. Beautified code is normally larger than the input, so Change is normally a positive number, such as plus 4 percent in the worked example on this page. A negative number would mean the output came out smaller, which almost never happens when beautifying.
No. This tool offers 2 spaces or 4 spaces only, with no tab option. If your project uses tabs, format with 2 spaces here and convert the leading spaces to tabs in your own editor afterwards.
If your SVG is already tidy, try the SVG Minifier to shrink it for faster loading.