XML Formatter & Beautifier

Paste well-formed XML and reprint it with the indent you choose. The browser parser does not fetch external entities.

Use this tool

The file is read on this page and is not uploaded.

Result

The result appears in this panel after you run the tool.

About this tool

Beautify and pretty-print mean one reprint: the document is parsed and written again with nested elements on their own indented lines. A successful result means the XML was well formed enough for the browser parser. It does not mean the document matches a schema, and it does not mean every original space was kept.

Use it to read a minified feed, a config file, or a SOAP payload before you diff it. Broken markup stays an error. The parser does not request DTDs or other external entities, and the source is not uploaded.

The result remains XML, so the next suggestions are tools that accept XML rather than a hard-coded list.

How to use it

  1. Paste an XML document, or choose a local file. The file is read on this page and is not uploaded.
  2. Choose an indent, then Format XML. Ctrl+Enter or Cmd+Enter does the same thing from the box.
  3. Copy or download the reprint. Markup that is not well formed is reported and is not repaired.

Limitations

Well-formed XML, reprinted with indent

The browser parser has to accept the document

The formatter parses with the XML parser and stops when that parser reports an error. The message says the XML is not well formed and that the tool does not try to repair it. No missing end tag is invented. No illegal character is stripped so the rest can print. When the parse succeeds, the document is serialized and then broken onto lines. Indent is two spaces, four spaces, or a tab. A tag that closes an element decreases the indent before the line is written. A start tag that is not a closing tag, not empty, and not a processing instruction increases the indent after its line.

Whitespace that sits only between tags is removed before the line split, so a pretty gap you already had is replaced by this indent. Text inside an element stays with the serialization. The page does not validate an XSD or a DTD beyond what the browser parser does while checking well-formedness. An unknown element name is fine. A schema-invalid document that is still well formed is printed.

Attributes, declarations, and the minifier

Attribute order follows the serializer. Do not treat the reprint as a byte-identical archive. The XML declaration is part of the document the parser kept, not a row in a table. The minifier is a different page: it deletes comments and pulls tags together without checking well-formedness. This formatter can fail on a document the minifier would shorten. Use the formatter when you need to read a document that parses. Use the minifier only when you accept a textual squeeze.

Conversion is not formatting

Turning XML into JSON or CSV parses with a different library and renames attributes with a prefix. Those pages can turn digit text into numbers or into table cells. This page does not. A successful format means the same document structure, indented. Comments the parser retains can appear in the serialization. If your goal is a table, pick a conversion and expect columns. If your goal is a readable document, stay here.

Privacy

Your XML is processed in your browser and is not uploaded to UtilChain. File names, source text, and results are not sent to analytics.