XML Formatter and Prettifier
Format, indent, and validate XML documents with customizable indentation and output options.
XML Formatter and Prettifier tool
Example
Input: <note><to>Ada</to><body>Hi</body></note> then click Format XML
Result: <note> / <to>Ada</to> / <body>Hi</body> / </note> (child lines indented 2 spaces)
Each element starts on its own line and nesting adds one indent level. Elements that contain only text stay on one line, and comments and CDATA are kept.
- Paste your raw, minified, or poorly formatted XML into the input text area.
- Select the indentation style - choose between 2 spaces, 4 spaces, or tabs.
- Click "Format XML" - the formatter validates your XML first, reporting any well-formedness errors with line and column numbers.
- View the beautifully indented and structured XML output with proper nesting.
- Optionally click Minify to compact the XML instead of formatting it.
- Click the copy button to copy the formatted or minified XML to your clipboard.
Formatting and Validating XML
An XML formatter puts each element on its own line and indents it by nesting level, so a dense one-line document becomes easy to read. This one checks that the XML is well-formed first, and it can minify a document instead. Well-formed means the basic XML rules are followed. Every tag is closed, elements nest without overlapping, attribute values are quoted, and there is exactly one root element. If a rule is broken, the formatter stops. It shows the line and column of the problem rather than guessing at a fix. It does not check the document against a schema (XSD or DTD), which is a separate step.
Choose 2 spaces, 4 spaces or tabs and click Format XML. Elements that hold only a short piece of text stay on one line, such as <to>Ada</to>. Elements with children open and close on separate lines. The XML declaration, comments, CDATA sections, processing instructions and DOCTYPE lines are all kept. Text is trimmed as it moves onto its own line, so check the result where spaces inside mixed text matter.
Minify does the opposite. It removes the gaps between tags that hold only whitespace, giving a compact document while keeping text, comments and CDATA. To turn the XML into data for your code, use the XML to JSON Converter. For JSON documents, the JSON Formatter works the same way.
Sources
Frequently Asked Questions
Related Tools
JSON to XML Converter
Convert JSON data to well-formed XML documents with customizable root element and formatting options.
Developer ToolsXML to JSON Converter
Parse XML documents and convert to structured JSON, with attributes kept as @_-prefixed keys and well-formedness checks.
Developer ToolsJSON Formatter and Validator
Format, validate, beautify, and minify JSON data with a collapsible tree view and line-and-column error detection.
Developer ToolsYAML Formatter and Viewer
Format, validate, and visualize YAML documents with tree view and customizable indentation.
Developer Tools