XML Beautify/Minify
Format, minify, and validate XML documents. Beautify adds indentation; minify collapses whitespace; validation checks well-formedness.Overview
The XML Beautify/Minify tool provides:- Beautify — Indents tags with 2 spaces using
xml-formatter - Minify — Removes whitespace between tags
- Validation — Parses XML with
fast-xml-parserto detect errors
Use Cases
XML cleanup
Format XML from APIs, databases, or legacy systems for readability
File size reduction
Minify XML configuration files or SOAP messages
Validation
Check XML well-formedness before processing or transmission
Debugging
Beautify minified XML from third-party services
Actions
- Beautify
- Minify
Uses the Output:
xml-formatter library to indent tags with 2 spaces. Preserves CDATA, comments, and attributes.Input:Validation
The tool validates XML before beautification or minification usingfast-xml-parser. If the XML is malformed, an error is returned.
Example: Invalid XML
Example: Invalid XML
Input:Output:
Implementation Details
The tool importsfast-xml-parser for validation and xml-formatter for beautification.
Source: lib/tools/engine.ts:544-549
Key logic
The minify operation is a simple regex (
/>\s+</g) and does not preserve whitespace-sensitive content inside text nodes or CDATA.XML Feature Support
Namespaces
Namespaces
CDATA sections
CDATA sections
xml-formatter does not modify CDATA content.Processing instructions
Processing instructions
<?xml ... ?>) are preserved.Comments
Comments
Keyboard Shortcuts
Cmd/Ctrl+Enter— Beautify (default)Cmd/Ctrl+Shift+C— Copy outputCmd/Ctrl+Shift+S— Download output
Related Tools
HTML Beautify/Minify
Format or minify HTML markup
JSON Format/Validate
Validate and format JSON
YAML to JSON
Convert YAML to JSON