How does the XML well-formed check catch tag errors by line?
The validator tokenizes your document into opening, closing, self-closing, comment, CDATA, and text nodes, then walks a tag stack to verify structural well-formedness. Any mismatch throws a ParseError with the exact 1-based line and column number.
| Well-formedness violation | Error reported by parser | Typical cause |
|---|---|---|
| Missing closing tag | <book> is never closed |
Deleted or truncated </book> at file end |
| Wrong nesting order | Expected </title> but found </book> |
Overlapping tags such as <a><b></a></b> |
| Extra closing tag | </item> closes a tag that was never opened |
Duplicate closing tag after refactor |
| Multiple top-level tags | XML must have exactly one root element |
Concatenated log snippets without a wrapper |
Unescaped < in text |
A "<" that doesn't start a tag (write < instead) |
Math comparison x < 5 outside CDATA |
Detecting unclosed, mismatched, and multi-root elements
Under the W3C Extensible Markup Language (XML) 1.0 Specification, an XML processor must reject documents that violate nesting or single-root rules. This XML beautifier checks every opening tag against the stack and rejects stray non-whitespace text outside the root element.
When debugging multi-format API integrations where services exchange both XML and JSON, you can inspect the XML structure here and format and validate JSON API responses in the companion tool.
Jumping to exact line and column errors with Go to line
Large configuration files and SAML assertions often span thousands of lines, making manual tag counting tedious. When checkXml() detects an error, the editor displays the human-readable message alongside a Go to line button.
Clicking Go to line focuses the input textarea, scrolls the offending line into view, and selects from the exact column to the end of the line. You can fix the missing slash or unescaped < immediately and watch the Formatted panel update live.
XML indentation options, mixed inline content, and xml:space
Switching Mode to Format indents nested elements cleanly while respecting inline text boundaries and whitespace-preservation attributes. Unlike naive line-by-line regex formatters, the block analyzer inspects child nodes before adding newlines.
Tip: Open
.svgvector files directly via Open file to inspect messy Illustrator or Figma exports with clean 2-space indentation before editing paths by hand.
Choosing 2 spaces, 4 spaces, or Tabs in Format mode
Use the Indent dropdown to switch between 2 spaces, 4 spaces, and Tabs. The formatter also normalizes extra whitespace between attributes inside tags while leaving quoted attribute values ("..." and '...') untouched.
For .svg assets that are already valid and need aggressive size reduction for web delivery, you can minify SVG markup and strip redundant editor metadata instead of only re-indenting tags. Both tools share the same W3C Scalable Vector Graphics (SVG) 2 Specification XML foundation.
Preserving mixed inline elements and CDATA blocks
Many pretty-printers corrupt documentation and XHTML-style XML by putting <p>, <b>, and </b> on separate lines, which introduces unwanted spaces in rendered text. Here, analyzeXmlBlocks() detects mixed text-and-element children and keeps the entire inline block on a single indented line.
Elements carrying xml:space="preserve" and leaf <![CDATA[...]]> blocks are also kept intact without injecting internal line breaks. Only multi-line pure-text blocks or nested container elements expand across lines.
Why XML vs HTML parsing rules differ, and when to minify XML markup
HTML5 browsers silently auto-close missing tags and reorder broken nesting, whereas XML parsers fail immediately on the first syntax error. Understanding that strictness explains why an HTML snippet often fails XML validation until self-closing tags and entities are fixed.
Strict XML fatal errors vs forgiving HTML5 recovery
As documented in the MDN DOMParser Web API Reference, parsing with text/html applies error-recovery rules, while application/xml or text/xml halts on a <parsererror>. Unclosed <br> or <img> tags, unquoted attributes, and bare & characters are valid in HTML5 but fatal in XML.
When your goal is turning rendered HTML markup into a printable document rather than strict XML serialization, switch to HTML to PDF document rendering instead of forcing HTML through an XML validator.
Stripping comments and whitespace safely in Minify mode
Selecting Minify removes <!-- ... --> comments, collapses redundant attribute spacing, and trims inter-element newlines to shrink payload size. Any element marked with xml:space="preserve" retains its exact internal whitespace and tag formatting, protecting preformatted code snippets or address blocks from accidental collapse.
Minifying is ideal before embedding XML in test fixtures, SOAP requests, or database columns where extra indentation wastes bytes. Switching back to Format restores readable indentation on the minified output whenever you need to audit the tree structure again.
Inspecting SOAP envelopes, SAML assertions, RSS feeds, and XSD files locally
Formatting XML in the browser avoids uploading authentication tokens, partner schemas, or proprietary feeds to third-party servers. Everything runs in local memory with zero network calls, and automatic worker offloading keeps large documents responsive.
- Accepted file formats: Click Open file or drag and drop
.xml,.svg,.xsd,.rss, or.atomfiles up to20 MBdirectly into the input pane, then download the result asformatted.xml. - Responsive large-file handling: Inputs larger than
65,536characters (64 KB) automatically run inside a dedicated Web Worker with a120 msdebounce so the UI stays responsive. - Debugging SOAP and SAML: Paste base64-decoded SAML assertions or SOAP envelopes to trace namespace prefixes and nested signatures without exposing identity tokens to external servers.
- Exporting tabular XML data: When an XML feed contains repeating records you need to analyze in a spreadsheet, convert repeating XML records into spreadsheet tables after checking well-formedness here.