Tools
XML Formatter
The XML formatter parses and pretty-prints XML documents with configurable indentation and syntax highlighting. It validates well-formedness and reports errors with location information so you can quickly find and fix problems. The tool handles standard XML including namespaces, CDATA sections, and processing instructions, making it useful for developers working with REST APIs, SOAP services, configuration files, and data feeds.
What is the XML Formatter?
The XML formatter takes raw or minified XML and produces a consistently indented, human-readable version. It checks for well-formedness — proper nesting, closed tags, valid attribute quoting, and legal character usage — and reports violations with line and column numbers. Syntax highlighting distinguishes element names, attributes, text content, comments, and processing instructions. The tool does not perform schema validation (XSD or DTD) but ensures the document is at least structurally valid XML.
How does it work?
Paste your XML into the input area and click Format. The tool parses the XML using a browser-based parser, checks for errors, and serializes the document tree with configurable indentation. If parsing fails, the error is displayed with the line and column where the parser stopped. Namespace declarations and CDATA sections are preserved. The formatted output can be minified back to a single line if needed for transmission or storage.
Typical Use Cases
- Formatting SOAP response bodies for manual inspection and debugging
- Validating XML configuration files before deployment
- Cleaning up auto-generated XML from Java or .NET serializers
- Preparing readable XML examples for API documentation
Step-by-step Guide
- Step 1: Paste your XML into the input area.
- Step 2: Choose indentation width (2 spaces, 4 spaces, or tab).
- Step 3: Click Format to pretty-print or Minify to compress.
- Step 4: Copy the formatted output for use in your project.
Example
Input
<root><item id="1"><name>Alice</name></item></root>
Output
<root>
<item id="1">
<name>Alice</name>
</item>
</root>
Tips & Notes
- XML is case-sensitive — <Item> and <item> are different elements.
- All attribute values must be quoted; unquoted attributes are not valid XML.
- If your document starts with a BOM (byte order mark), remove it — it can cause parsers to reject the file.
Frequently Asked Questions
What is the difference between well-formed and valid XML?
Well-formed XML follows the structural rules of XML (proper nesting, closed tags, etc.). Valid XML additionally conforms to a schema (XSD or DTD) that defines which elements and attributes are allowed. This formatter checks well-formedness only.
Can I convert XML to JSON with this tool?
No, this tool only formats XML. Use the xml-json converter tool to transform between XML and JSON formats.
XML Formatter
Format and prettify XML documents with syntax highlighting, line numbers, indentation, and structure statistics.
Open Tool