XML Formatter
NewIndents XML without editing it: mixed content keeps its spacing, and a tag that does not match is named with the line it is on.
Runs entirely in your browser
Loading tool...
How to use
- Paste your XML — a whole document, a fragment, an API response.
- Format it, or minify it to strip the whitespace between tags.
- If the markup is not well-formed, the error names the tag and the line to look at.
- Copy the result or download it as a file.
Features
- Re-indents element-only content and copies mixed content through untouched, so a space between words is never invented or removed.
- Attribute order, values and quote style survive the round trip.
- Keeps the XML declaration, DOCTYPE, processing instructions and CDATA sections exactly as written.
- Names mismatched, unclosed and unquoted markup with the line it starts on, instead of failing with a position number.
- Runs entirely in your browser — the document is never uploaded.
Frequently asked questions
- Is this a validator?
- It checks well-formedness: that every tag is closed by its own name, that attributes are quoted, and that comments and CDATA sections end. That is the class of problem that stops a parser dead. It does not check the document against a DTD or an XSD, so an element that is well-formed but in the wrong place under a schema still formats.
- Why is part of my XML left on one line?
- Because it holds text next to elements. In <p>See <b>this</b> page</p> the spaces around the tags are content: indenting it would add whitespace a reader can see. Content made only of elements is re-indented; content that mixes text and elements is left exactly as you wrote it.
- Can I use it on HTML?
- Mostly no, and it will say so. HTML allows unquoted attributes, bare attributes such as disabled, and tags that never close — all of which XML forbids and this tool reports as errors. Use the HTML minifier for HTML, or convert to XHTML first.
- Does minifying change what the document means?
- It removes the whitespace between elements, which no XML parser treats as data, and optionally the comments. Text inside an element and everything in a CDATA section are kept byte for byte, so the values a program reads out are identical.
Related tools
Format and beautify JSON instantly.
Format or minify a query with a real scanner, so a keyword inside a string or a comment is left exactly as you wrote it.
Shrinks HTML without changing what it renders — the space between two inline elements is a word gap, and it is kept.
Convert XML to JSON with the array question answered out loud rather than guessed at.
Indent HTML without changing what the page renders — no line break lands where a space was not already allowed.