SVG Code Formatter: Format SVG Code with Clean Indentation
Turn minified SVG into readable, indented markup. Only whitespace changes, never the image.
SVG Code Formatter tool
1Add your SVG
2Adjust the options
3Preview and download
Input and output codeView, edit and copy the code
Under the hood
How SVG Code Formatter works
An SVG code formatter turns minified or messy SVG into neatly indented, readable markup. Only whitespace changes, so the SVG renders exactly the same.
Tokenize the markup
The SVG text is split into tags, comments, text nodes and declarations without altering their content.
Regex tokenizerIndent by nesting depth
Each opening tag increases the depth and each closing tag decreases it. You choose 2 spaces, 4 spaces or tabs.
Depth counter- One lineWrapped
Wrap attributes (optional)
Elements with three or more attributes, or long lines, can have one attribute per line for easy diffing.
Attribute splitter Show the structure
A chart counts lines at each nesting depth, giving you a quick picture of how deep the SVG goes.
Depth histogram
Why format SVG code
- Easier reading and diffs
- Indented code makes structure and changes obvious.
- Rendering is unchanged
- Whitespace between tags does not affect how SVG renders.
- Your style
- Pick 2 spaces, 4 spaces or tabs to match your project.
Step by step
SVG Code Formatter process
Four steps format an SVG. The preview confirms nothing changed visually.
Paste your SVG code
Drop a file or paste code. A one-line export is a great test.
Tip: The input box shows your code.
Choose indentation
Pick 2 spaces, 4 spaces or tabs.
Tip: The output reformats instantly.
Wrap attributes if needed
Switch on One attribute per line for long tags.
Tip: Helps code review.
BeforeAfterCopy or download
Press Copy code or Download.
Tip: Copying from the preview gives the full output.
Reference
SVG Code Formatter settings / conversion chart
The table lists formatting options. The chart explains the depth histogram.
Lines per nesting depth (example)
At a glance
- Converts best: Depth 2.
- Needs the most care: Depth 4.
Most SVG lines sit at depth 2–3, inside groups.
| Option | Values | Effect |
|---|---|---|
| Indentation | 2 spaces, 4 spaces, tabs | Width of each nesting level |
| One attribute per line | Off or on | Splits long tags for readability |
| Text nodes | Kept inline when short | Keeps <text> readable |
| Comments | Kept | Formatting never deletes them |
Answers
SVG Code Formatter FAQ
Questions people ask about the SVG Code Formatter, answered for this specific use case.
Does formatting change how my SVG renders?
No. Only whitespace between tags changes.
Can I choose tabs instead of spaces?
Yes. Pick Tabs in the Indentation control.
Will it fix invalid SVG?
No. Use the SVG Validator to find problems.
Does it keep my comments?
Yes. Comments are left in place.
Is my code uploaded?
No. Formatting runs in your browser.
All converters
Every free converter and SVG tool
43 free tools that run in your browser. Pick a converter below, or search by format or task.
No converter matches that search. Try “SVG”, “logo” or “PNG”.