XML Formatter
Format, indent, and validate XML documents. Detects malformed tags, unclosed elements, and bad attributes with clear line-level error messages. Great for config and API work.
How to use the xml formatter
Paste XML into the input box and press Format to pretty-print and validate. Errors point to the first parse failure.
Formula & explanation
Validation: DOMParser. Pretty-print: insert newlines and 2-space indent at each tag boundary, preserving text content.
Examples
<root><a>1</a></root> formats with each tag on its own line.
Frequently asked questions
- What XML dialects does this support?
- Any well-formed XML — RSS, SVG, XHTML, SOAP, and custom schemas all work as long as the syntax is valid.
- Why does the formatter show an error on my file?
- XML is strict: every tag must be closed, attribute values must be quoted, and special characters like & must be escaped as &. The error message points to the first violation.
- Does this validate against a schema (XSD/DTD)?
- No — it checks well-formedness only, not schema validity. For full XSD validation you need a server-side tool.
- Is my XML sent to a server?
- No. Parsing and formatting happen entirely in your browser using the built-in DOMParser API.
Related developer tools tools
- YAML FormatterFormat and validate YAML for config files, Kubernetes manifests, Docker Compose, and CI pipelines. Normalizes indentation and surfaces syntax errors.
- SQL FormatterPretty-print and format SQL for any major dialect — MySQL, PostgreSQL, SQLite, T-SQL, and more. Normalizes indentation, keywords, and spacing for readable, consistent queries.
- JSON FormatterPretty-print, minify, and validate JSON. Detects syntax errors with line numbers and supports nested structures of any depth.
- JSON to XML ConverterConvert JSON objects and arrays to well-formed XML. Maps object keys to elements, array items to repeated elements, with optional root wrapper.
- XML to JSON ConverterConvert XML to JSON for legacy API integration, SOAP responses, and config migration. Handles attributes, namespaces, and text content.
- XML to CSV ConverterFlatten repeated XML elements into CSV rows with attributes and child text as columns. Great for opening XML data in Excel or Sheets.