XML Formatter
Paste raw or one-line XML and this tool re-indents it into clean, readable marku
Paste raw or one-line XML and this tool re-indents it into clean, readable marku
How to use XML Formatter
- Paste your XML into the input box.
- Choose Beautify or Minify, and pick an indent size for beautify.
- Copy or download the formatted XML from the output.
About XML Formatter
Paste raw or one-line XML and this tool re-indents it into clean, readable markup, or collapses it back to a single minified line. Choose 2 spaces, 4 spaces, or tab indentation. As it formats, it also checks that the document is well-formed and flags the first problem it finds, such as a mismatched, unclosed, or unexpected closing tag.
The formatter uses a custom tokenizer rather than a strict validating parser, so it preserves the parts other tools often mangle: comments, CDATA sections, processing instructions like the XML declaration, and DOCTYPE declarations all pass through untouched. Attribute values that contain a greater-than sign inside quotes are handled correctly. An element that holds only text is kept on one line (for example, a tag wrapping a value), while nested elements are placed on their own indented lines.
Everything runs locally in your browser using plain JavaScript. Your XML is never uploaded to a server, so it is safe to use with internal configs, API payloads, or private data. It does not resolve external entities, validate against a DTD or schema, or check namespaces, and minifying trims whitespace around tags, which can affect documents where that spacing is significant.
Frequently asked questions
- Does it validate my XML?
- It checks that the document is well-formed: every open tag must have a correctly nested matching close tag. If a tag is mismatched, unclosed, or unexpected, it reports the first error instead of producing output. It does not validate against a DTD, XSD schema, or namespace rules.
- Is my XML uploaded anywhere?
- No. All parsing and formatting happen entirely in your browser with JavaScript. Nothing is sent to a server, so it is safe for internal configuration files, API responses, and other private data.
- What is the difference between beautify and minify?
- Beautify pretty-prints your XML with line breaks and indentation so nested structure is easy to read. Minify strips whitespace between and around tags to produce a compact single line, which is smaller for transport but harder to read.
- Does it keep comments, CDATA, and the XML declaration?
- Yes. Comments, CDATA sections, processing instructions (including the <?xml ... ?> declaration), and DOCTYPE declarations are all preserved exactly as written. Only insignificant whitespace between tags is changed.
- Will minifying ever change my data?
- Minify and beautify both trim whitespace that sits around tags, so if your document relies on significant whitespace inside mixed text-and-element content, that spacing may not be preserved. Attribute values and element text are otherwise kept intact.
- Can I download the result?
- Yes. Use the Copy button to put the output on your clipboard, or Download .xml to save it as a file. Both act on the formatted or minified output currently shown.