XML Formatter
Validate and format XML markup.
Validate and format XML markup.
Machine-generated XML, such as an API response, a sitemap, an RSS feed or a configuration export, often arrives as one long line. Reading it that way is slow and error-prone. This tool parses what you paste and writes it back with a line break between neighboring tags, so the structure becomes visible at a glance. It is a practical first step before reading, diffing or debugging a document you did not write yourself.
The parsing is done by the browser's own DOMParser, the same engine that reads XML for web pages. If the text is not well-formed, the output box shows the message Invalid XML instead of a result. That makes the page useful as a quick check for unclosed tags, mismatched names, unescaped ampersands or a missing root element. Because this is the browser's standard XML parsing, results match what other web-based XML tools would accept as well-formed.
It is worth knowing exactly what the Format button does. It re-serializes the parsed document and inserts a newline between every closing and opening angle bracket. It does not add indentation, and it does not minify. Existing whitespace between tags is kept, so XML that was already indented will look much the same afterward. For deeper reformatting with indentation, use an editor that has a pretty-print command and treat this page as a quick checker.
When a web service returns XML without any line breaks, formatting it puts each tag on its own row. You can then scan for the field you want instead of searching through a single dense line. It is a small step that saves real reading time.
If an importer or parser rejects your file, paste the content here. An Invalid XML message confirms the problem is the markup itself, such as a stray ampersand, and not your application code. If it parses here, look elsewhere for the cause.
Before publishing a sitemap.xml or an RSS feed, run it through the parser to confirm it is well-formed. Line breaks make it easier to check that every URL entry has the tags you expect. This catches mistakes before readers or crawlers meet them.
Version control shows changes line by line. Putting elements on separate lines first makes a diff of two XML snippets far more readable than comparing two enormous lines. Comparing before and after becomes straightforward. It also helps when pasting snippets into a bug report.
Parsing and formatting happen in your browser through its built-in XML parser. The markup you paste is not sent to any server.
It checks that the document is well-formed, meaning tags are properly nested and closed, there is one root element and special characters are escaped. It does not validate against a schema or DTD, so it cannot tell you whether the content is semantically correct.
The tool reports a general error when the browser parser fails, and it does not pass along the parser's position details. To find the problem, check for mismatched tags, missing quotes around attribute values, a raw ampersand, or a second root element.
No. It inserts a line break between adjacent tags but does not add leading spaces for nesting. If your input already contains indentation or line breaks, those stay as they were, so the output will look similar. For nested structure, use an editor with a pretty-print command.
No. The Format button only adds line breaks. To shrink XML you would need to remove the whitespace between tags separately, for example with an editor's find and replace on the gaps between closing and opening brackets. Minifying also needs care around text content, where whitespace can matter.
Common causes are an opening tag that is never closed, tags closed in the wrong order, attribute values without quotes, unescaped ampersands or angle brackets in text, mismatched capitalization, and having more than one top-level element. Fixing these one at a time and reformatting usually clears the error.
No. The parse and the serialization both happen inside your browser tab. That makes it fine for internal configuration snippets, though you should still avoid pasting credentials into any web page out of habit. If you work with confidential data, remove anything sensitive before sharing screenshots of the output.