Skip to content
Sealpaste

Delete all recent work?

This removes the 0 items saved in this browser. Your settings stay.

Stop saving recent work?

New work won't be saved in this browser. The 0 items already saved can stay or go.

XML Formatter

XML

Paste XML, or

CtrlV paste · Ctrl↵ run now

Formatted XML
Ready
Ln 1, Col 1
Runs in your browser. Nothing you paste is uploaded unless you share it.

Format or minify XML, browse it as a tree, run XPath and validate against an XSD or DTD

Indent XML so you can read it, or minify it onto one line. Broken XML gets the line, the column and the reason.

How to use it

  1. Paste XML on the left, or open a .xml, .svg, .xsd or other XML file.
  2. Choose Format or Minify, the indent, and whether comments stay.
  3. Copy or download the result. Any error is marked in your text with its line and column.
  4. Pick Explore to fold the document as a tree, run an XPath expression, or Validate it against an XSD or a DTD; each line number takes you to that place in your text.

Examples

Indent a SOAP response

Input
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetPriceResponse><Price>34.50</Price></GetPriceResponse></soap:Body></soap:Envelope>
Result
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetPriceResponse>
      <Price>34.50</Price>
    </GetPriceResponse>
  </soap:Body>
</soap:Envelope>

A tag never closed

Input
<config>
  <port>8080</port>
  <host>localhost
</config>
Result

Line 4, column 1Expected </host> but found </config>

The reason comes with the line and column, and the place is marked in your text.

What formatting changes, and what stays as written

Only the whitespace between elements changes. Text, attribute values, CDATA sections, the DOCTYPE and any comments you keep stay exactly as written, entities like &amp; included, so the document means the same and formatting it twice gives the same text.

Where spaces are part of the text, the element is written exactly as it came: mixed content such as <p>Hi <b>you</b></p>, and any element with xml:space="preserve".

Safe with untrusted XML

Entities a DOCTYPE declares are kept as written, not expanded, and nothing outside your text is fetched. That is why an XML bomb ("billion laughs") or an external entity that reads a file (XXE) does nothing here. Only the five built-in entities and character references like &#169; are read.

What it checks

Well-formedness, as the XML 1.0 rules define it: one root element, every tag closed in order, attributes quoted and not repeated, legal names and characters. Namespace prefixes are kept as part of the names. Validation against a schema is in Explore, below.

The errors you are most likely to see, and the fix:

  • A lone "&" isn’t allowed: write it as &amp; (as in Tom &amp; Jerry).
  • Attribute values must be in quotes: write id="1", not id=1.
  • Expected </a> but found </A>: names are case-sensitive, so the closing tag must match exactly.
  • Only one root element is allowed: wrap the elements in one, such as <items>…</items>.
  • <?xml …?> may only stand at the very start: delete any space or line before it.

Explore: tree, XPath and validation

Tree shows every element with its attributes and text, folded or open, with where each starts in your text. XPath runs an XPath 1.0 expression (every axis but namespace, predicates, and the core functions such as count(), contains() and sum()) and lists the nodes it selects or the number, text or true/false it returns. Names match as written, prefix included, so a default namespace needs no prefix.

Validate checks the document against an XSD you paste (elements, sequence, choice and all with min and max occurrences, attributes, required and fixed values, built-in types such as xs:int and xs:date, and restrictions: enumerations, patterns, lengths and ranges) or a DTD (content models, EMPTY, mixed content, attribute types, #REQUIRED and #FIXED, unique IDs and the IDREFs that point at them). With nothing pasted, it uses the declarations in the document’s own DOCTYPE. Each problem comes with its line and column.

Nothing is fetched: a schema that imports or includes another file is checked with what you pasted, and the page says what it could not read. xs:key, xs:keyref and xs:unique are not checked.

Questions

Can it read SVG, RSS, Android layouts or .csproj files?
Yes: they are all XML. Open the file or paste its text; the formatter reads any well-formed XML 1.0.
Why is one element left on a single line?
It holds text beside other elements (mixed content), or says xml:space="preserve". Adding line breaks there would change the text, so it is written as it came.
How do I validate XML against an XSD?
Paste the XML, pick Explore, then Validate, and paste the XSD in the box. Every problem is listed with its line and column, such as an element the schema doesn’t expect there, a missing required attribute, or a value outside its type (a date that doesn’t exist, a number above maxInclusive). A DTD works the same way, or leave the box empty to use the DOCTYPE in the document.
Which XPath does it run?
XPath 1.0: paths and every axis but namespace, predicates such as [@id="2"] and [last()], unions with |, comparisons and arithmetic, and the core functions (string, number and boolean ones such as concat(), substring-after(), normalize-space(), count() and sum()). Element names match as you write them, so a document with a default namespace works without a prefix.
Is my XML uploaded?
No. Everything runs in your browser, so your XML stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with your password first. SOAP messages, config files and exports often hold passwords or keys, and the page warns you if it spots any.

Related tools