Paste XML that arrived as one long line and get it back with each element indented under the one it sits in, after a check that every tag is closed.
FluffyShieldProtected workspace
Loading the tool…
The tool didn't load. Reload the page, or check whether an extension or network filter blocks .
Free · No upload · No sign-up · No usage quotas
Why is one line still long after formatting?
Because it holds words. Inside an element with text in it, a new line or an indent would become part of the text, so the formatter doesn't touch it.
FluffyBench · 3 min read · Reviewed
Formatting XML
Check that every tag is closed and nested in order
→Put each element on a line of its own, indented
→Leave any element that holds words as it was
What it does
Open tags named
Leave the badge's rectangle without its closing slash and nothing is formatted; the message reads "Opening and ending tag mismatch: "rect" != "svg"".
Checked as XML, not as SVG
A rectangle with width="wide" formats without a word. A width SVG can't draw is still correctly written XML.
Comments get a line
A note such as <!-- badge v2 --> between two tags is moved onto a line of its own, at the same indent as its neighbours.
Limits An <!ENTITY> line or a <!DOCTYPE> with a [ ] part is refused, and so is a named character like that only such a line could define.
A sale badge saved as one long line
The shop's "Sale 40% off" badge is an SVG file: a drawing written out as text, with a tag for the green rounded rectangle and a tag for the words on top of it. The designer's program saved all of it on a single line, and the green no longer matches the new shop colours. Somewhere in that line is the colour to change.
SVG is written in XML, where each piece sits between an opening tag such as <text> and a closing one, </text>, or in a single tag ending />, and pieces sit inside one another. Pasted into the formatter, the badge comes back on four lines, the rectangle on a line of its own with fill="#2a6f4e" where you can see it. One line, the badge's words, is just as long as before.
Two kinds of white space
Some white space sits between tags, like the gap between the end of the rectangle and the start of the text. That gap holds no words, so the formatter can put a line break and an indent there, or take them out, and the badge still says exactly the same thing.
The rest sits inside an element that holds words. The XML specification says a reader must pass every character that isn't a tag on to the program, so there a line break or an indent would become part of the text itself. The badge's <text> holds "Sale", a bold "40%" in a <tspan> of its own, and "off", with a space either side of the bold part:
Gaps, then words
The badge after formatting, and the pieces of its text element. How we checked
The formatter can't know which spaces a program cares about, so inside any element with words in it, it changes nothing, tags and all. On a badge that costs one long line. On a page of writing, where nearly every element holds words, most of the file stays as it came.
Tidying the badge
Paste the badge's code into the XML box.
Pick 2 spaces or 4 spaces from the Indentation list above the boxes.
See the result in the second box, which a phone shows under the Result tab.
Press Copy to take the formatted XML to your editor.
Formatting also checks the file. If it comes back formatted, every tag is closed and nested in order and every attribute is in quotes, which the XML specification calls well formed. That isn't the same as valid: a valid file also follows a list of allowed elements, its document type, and this tool doesn't read one. For a yes or no without formatting, choose Validate in the JSON formatter with XML under Language; a file that passes reads "Well-formed XML".
You've changed the colour and want the badge back on one line