Developer Tools
XML Formatter
Format, minify, and validate XML in your browser. Pretty-print with 2 or 4 space indent, sort attributes, and get precise line and column errors.
Mode
Pretty-print XML with indentation and a single tag per line.
Indent
Attribute order
Keep the attribute order from the input.
XML is parsed and rendered entirely in your browser. The markup you paste is never sent to a server.
Output
How to use
- Paste your XML into the input area, or click a sample like RSS feed, SOAP envelope, sitemap.xml, pom.xml, or AndroidManifest.xml.
- Pick a mode: Format to pretty-print, Minify to strip whitespace, or Validate to only check well-formedness.
- In Format mode, choose 2 spaces, 4 spaces, or Tab indent and decide whether to preserve attribute order or sort A to Z.
- Read the output panel and document stats; on errors, the line and column point to the exact problem so you can fix it fast.
About this tool
XML Formatter parses any XML document in your browser and rewrites it three ways. Format pretty-prints the markup with 2-space, 4-space, or tab indentation, with one element per line, attributes preserved or sorted alphabetically, and mixed content (elements with significant text inside them) kept on a single line so meaning is not changed. Minify strips whitespace between elements for the smallest payload while leaving text content and CDATA sections intact, and reports the percent reduction. Validate checks well-formedness without rewriting and reports the exact line and column of the first error, which is what you want when an API or a build tool says XML failed to parse but does not tell you where. The parser is hand-rolled to follow the XML 1.0 specification: it understands the XML declaration (<?xml version="1.0" encoding="UTF-8"?>), processing instructions (<?target data?>), comments (<!-- ... -->) with the no-double-hyphen rule, CDATA sections (<![CDATA[ ... ]]>), DOCTYPE declarations, namespaces with colon-prefixed names (xmlns, xsi:schemaLocation, soap:Envelope), self-closing tags, attribute values quoted with either " or ', and the five built-in character references (&, <, >, ", ') plus decimal and hex numeric references. It catches the things browsers' built-in XML parsers silently allow but real consumers reject: duplicate attribute names on a single element, mismatched closing tags, unterminated tags or comments, < inside attribute values, the forbidden ]]> sequence in text content, multiple root elements, and malformed character references. Live document stats show element count, attribute count, max nesting depth, comments, CDATA sections, processing instructions, and unique element names so you can sanity-check the structure before shipping. Useful for SOAP envelopes, RSS and Atom feeds, sitemap.xml, pom.xml, AndroidManifest.xml, plist, SVG, OPML, OOXML fragments, KML, GPX, MusicXML, configuration for Spring, Hibernate, Maven, Gradle (settings.xml), and any XML you receive from a partner, an export, or a black-box API. Everything runs in your browser, so contracts, payloads, and config files never leave your device.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
JSON Formatter
Format, minify, and validate JSON in your browser.
Open tool
ConverterYAML to JSON Converter
Two-way YAML and JSON converter with anchors, flow, and block scalars.
Open tool
ConverterMarkdown to HTML Converter
Convert Markdown to clean HTML with a live preview and copy button.
Open tool
DeveloperHTML Entity Encoder Decoder
Two-way HTML entity encoder and decoder with named, decimal, and hex modes.
Open tool