Format XML

Prettify XML with consistent indentation while retaining attributes and text.

freeworks offlinenothing uploaded
ToolXML Formatter
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

The input is parsed with attributes preserved and rebuilt with configurable indentation and line breaks. Presentation whitespace changes while element names, attributes, and parsed text remain.

  • Two spaces are a readable source-control default.
  • Attribute preservation avoids changing document meaning.

Worked example

Prettify minified Maven pom.xml
Format a single-line pom.xml with proper indentation to make it readable
Input
											<project><modelVersion>4.0.0</modelVersion><groupId>com.example</groupId><artifactId>my-app</artifactId><version>1.0.0</version><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.13</version></dependency></dependencies></project>
										
Output
												<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0.0</version>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13</version>
    </dependency>
  </dependencies>
</project>
											

When to use this

Android and Maven files, SVG documents, and SOAP fixtures are formatted.

Edge cases

  • Mixed content can make added indentation visible text.
  • Malformed entities or tags fail parsing.
  • Processing instructions and declarations depend on parser preservation.

References