XML formatter
Indent XML structure while keeping mixed text, CDATA and comments intact.
- 1Add input
- 2Review and run
- 3Get your result
Tool input and files are processed in this browser without being uploaded.
Before you start
Paste compact XML or choose a UTF-8 file. Indent structural elements for inspection while preserving mixed text, CDATA, comments, processing instructions and xml:space regions.
How to use this tool
- Paste XML or choose one UTF-8 .xml or .txt file.
- Check the root and protected text regions; then format the XML.
- Review the whitespace warning and preview, then copy or download the complete result.
Supported inputs and limits
Indentation adds line breaks and replaces whitespace-only text between structural tags. Check whitespace-sensitive consumers before replacing the source.
Only XML 1.0 and UTF-8 are supported. DTD declarations and external entities are rejected. Paste is limited to 1 MiB, one file to 10 MiB, 200,000 elements and 128 levels.
Tag spelling, attribute quotes and entity references remain as written. Formatting does not check a business schema or repair invalid XML.
Worked example
Example input
<root><item>7</item></root>
Example options
{}Example output
<root> <item>7</item> </root>
When something does not work
Correct malformed XML or encoding, remove DTD declarations, and review whitespace-sensitive fields before replacing the source.
Frequently asked questions
Will formatting change text values?
Text-bearing and CDATA regions, including mixed content and xml:space="preserve" sections, remain as written. Structural indentation can replace whitespace-only text between child tags, so check consumers that rely on such whitespace.
Are comments, declarations and entities retained?
Yes. Comments, processing instructions, XML declarations, CDATA, attribute quotes and entity-reference spelling are retained. DTD declarations and external entities are rejected.
Can this repair invalid XML?
No. Invalid tags, namespaces, entities or attributes must be corrected first. The tool validates XML syntax, not a business schema.
Documentation & further reading
Related tools
JSON formatting workspace
Format or minify strict JSON, sort object keys, and encode or decode strings while preserving raw number tokens.
Regex tester
Try a pattern and see what it matches in your text.
Compare text
See what changed, side by side.
HTML formatter
Format HTML indentation so its structure is easier to read.