XML Formatter
Beautify and re-indent XML with consistent spacing, locally in your browser. Paste, format, and copy — nothing is uploaded.
Online XML Formatter & Beautifier
Paste XML, select two or four space indentation and click Format. The formatter orders elements by their apparent depth of nesting and keeps together declarations, processing instructions, comments, and CDATA blocks. The change occurs in your browser.
Format XML with correct indentation
Readable indentation helps surface a closing tag at the wrong depth or a section buried in a one line API response. It is also useful before code review where a structural diff is easier to understand than a change to one huge line.
This formatter is intentionally text-oriented and tolerant. It does not do strict xml parsing, match every opening tag to its closing tag, resolve namespaces, expand entities, or validate against a DTD or XSD. Therefore, a successful format does not imply that the document is well-formed or valid for a receiving system.
Whitespace may be data
Applications of XML may consider whitespace in text nodes significant. This formatter trims and reorders text within tags, so the output may not be semantically equivalent for mixed-content documents, signed XML, canonicalization workflows, or formats that are sensitive to whitespace.
Compare closely and keep the original. Do not run a formatter over digitally signed XML, expect the signature to remain valid; byte-level changes matter here.
Pick the tool that matches the job
- Use this page to make ordinary data-oriented XML easier to read.
- Use an XML parser or
xmllintwhen you need well-formedness checks. - Use the relevant XSD or application validator for contract validation.
- Use JSON to XML when you need a best-effort data conversion.
Need the data as JSON instead? Use XML to JSON or the JSON ⇄ XML converter. For web markup, see the HTML Formatter.
FAQ
How do I format XML online?
Paste the XML, choose an indent width, and click Format. Check the output before replacing the source especially when text whitespace is important .
Does formatting change my XML data?
Changes whitespace and can trim text between tags. That is often good enough for data-oriented XML, but it is not safe to assume equivalence for mixed content, canonical XML or signed documents.
Is my XML uploaded anywhere?
So the formatting logic runs in the browser instead of sending the XML to a conversion API. You should still scrub secrets and production sensitive data before editing in a web-based editor.