Skip to content
Jellykit

XML Formatter

Pretty-print or minify XML, and find out exactly where a document stops being well-formed, with the line, the column and a plain reason.

  • Runs on your device
Loading tool

About XML Formatter

Paste a feed, a config file or an API response and get it back indented one element per line, or squeezed onto a single line for sending. The document is checked first: if a tag is left open, an attribute is unquoted or an & is stray, you get the line, the column and a plain explanation instead of a result.

Only the whitespace between tags is changed. Text, attribute values, CDATA sections and elements that mix text with child tags are written exactly as they were, so formatting never alters what the document says.

How it works

  1. The XML is read by a well-formedness checker that follows the XML 1.0 rules: one root element, matched tags, legal names, quoted and unique attributes, and valid entity and character references.
  2. Pretty printing puts every element that contains only other elements on its own lines, indented by the amount you choose. An element that holds text keeps its content on one line, untouched.
  3. Minifying removes the whitespace between tags and nothing else. Elements marked xml:space="preserve" are always kept exactly as written.
  4. Attributes keep their order, values and quote marks; only the spacing between them is normalised to a single space.

Questions

Will formatting change my data?

No. Only whitespace that sits between tags is added or removed. Text inside elements, attribute values, CDATA and comments are copied as they are, and an element that mixes text with tags is left on one line exactly as written.

Why does it refuse my file?

It only formats well-formed XML, because guessing where a broken tag ends could produce a document that means something else. The message names the first problem and where it is; fix it and the result appears.

Does it check my XML against a schema or DTD?

No. It checks well-formedness, which every XML document must have. Checking against an XSD or a DTD is a separate step this tool does not do. Entities defined in the document’s own DOCTYPE are recognised.

How large a document can it handle?

Up to 5 MB of text, formatted as you type. Deeper than 1,000 levels of nesting is refused, since no real document needs it.

Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.