Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

SVG Code Prettifier & Indenter

Paste minified or messy SVG markup to prettify with proper indentation, or minify for production use

Your files never leave your browser
Input0 chars, 0 lines
Output0 chars, 0 lines
Ready·

Paste minified or messy SVG markup and get it formatted with proper indentation in one click — or go the other way and minify formatted SVGs down for production embedding. Sorting attributes alphabetically is built in too, which makes comparing similar elements much faster. And everything runs in your browser. Nothing gets uploaded.

How It Works

Paste SVG
→
Parse XML Tree
→
Rewrite with Indentation

The tool reads your SVG as an XML document, walks through every element and attribute, then rebuilds the markup with the indent size you picked (2 or 4 spaces). Minify mode does the opposite — it strips all optional whitespace and collapses the tree into a single compact string. Attribute sorting reorders attributes alphabetically on each element, which is handy when you’re comparing two similar SVGs side by side.

Examples

Formatting a minified icon

You copied a checkmark icon from a sprite sheet and it’s all on one line.

INPUT
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" fill="#4CAF50"/></svg>
OUTPUT
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"> <path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" fill="#4CAF50" /> </svg>

Minifying for inline HTML

Your formatted SVG is 14 lines long and you need it as a compact inline embed.

INPUT
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"> <circle cx="50" cy="50" r="40" stroke="black" fill="red" /> </svg>
OUTPUT
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" stroke="black" fill="red"/></svg>

Cleaning up Illustrator export with sorted attributes

Illustrator dumped attributes in random order across multiple <rect> elements. You want them consistent so you can spot differences.

INPUT
<rect y="10" fill="#f00" x="5" width="80" height="40"/> <rect height="40" x="5" width="80" fill="#0f0" y="60"/>
OUTPUT
<rect fill="#f00" height="40" width="80" x="5" y="10" /> <rect fill="#0f0" height="40" width="80" x="5" y="60" />

Who Uses This

🧑‍💻 Front-End Developers

Formatting inline SVG icons before committing them to version control so diffs actually make sense.

🎨 Designers

Cleaning up Figma or Illustrator exports to hand off readable code to developers.

📧 Email Developers

Minifying SVG logos and icons to keep email HTML file size under client limits.

📊 Data Viz Engineers

Prettifying D3-generated SVG output to debug chart rendering issues element by element.

Common Mistakes

Pasting HTML that wraps the SVG

If you paste <div><svg...></svg></div>, the formatter expects pure SVG. Strip the outer HTML tags first, then paste just the <svg> element.

Thinking formatting changes the image

Formatting only touches whitespace and line breaks. It won’t move a pixel, change a color, or alter any path data. The rendered result stays identical.

Over-minifying SVGs with embedded CSS

Some SVGs contain <style> blocks with CSS rules. Minification preserves these, but if you then run the result through a separate HTML minifier that strips whitespace inside style tags, selectors can break. Minify the SVG here, then leave the output alone.

Technical Details

Frequently Asked Questions

What is an SVG formatter?

It takes messy or minified SVG markup and adds proper indentation and line breaks so you can read it. Think of it like a code prettifier, but specifically tuned for the XML structure of SVG files. The visual output of the SVG doesn’t change at all — only the source code gets reorganized.

Does formatting an SVG change how it looks?

No. Formatting only affects whitespace between tags and attributes. Path data, colors, dimensions, transforms — none of that gets touched. Your SVG renders exactly the same before and after.

How much smaller does minification make an SVG?

Depends on how much whitespace was in the original. A well-formatted SVG with 4-space indentation typically shrinks by 20–40% after minification. If the file was already fairly compact, you might only save 5–10%. The stats panel shows the exact byte difference after you minify.

Can I format SVGs exported from Figma or Illustrator?

Absolutely. Design tools tend to export SVG with inconsistent indentation and attributes in random order. Paste the export here, turn on attribute sorting if you want, and you’ll get clean, consistent markup. All the graphic data stays intact.

Is my SVG data private?

Yes. The formatter runs entirely in your browser with JavaScript. Your SVG code is never uploaded, never stored on a server, and never leaves your machine. You can disconnect from the internet and it still works — that’s the proof.

Share: