The XML Formatter parses your XML using the browser's built-in DOM parser and re-serializes it with clean, consistent indentation. Because it parses the document first, it also validates your XML — any well-formedness errors are reported immediately with a description of what went wrong. You can also minify back to a single line when you need a compact payload.
1. Paste XML into the input box, upload a file, or click Sample to try an example.
2. The formatter runs automatically as you type.
3. Choose your preferred indentation — 2 spaces, 4 spaces, or tabs.
4. Click Minify to collapse to a single line.
5. Use Download XML or Copy Output to grab the result.
Does this tool validate my XML?
Yes. The formatter uses the browser's built-in DOMParser to parse your XML before formatting it. If the XML is malformed — unclosed tags, missing quotes on attributes, invalid characters — the tool reports the error rather than silently producing broken output.
What indentation options are available?
You can choose 2 spaces, 4 spaces, or a tab character per indent level using the buttons above the output.
Can I minify XML too?
Yes — click the Minify button to collapse the formatted XML back to a single line with all unnecessary whitespace removed. Useful for reducing payload size before sending to an API.
Does it handle XML namespaces and CDATA sections?
Yes. Namespace prefixes and declarations are preserved as-is. CDATA sections are kept intact and not re-encoded.
Is my XML sent to a server?
No. All parsing and formatting happens entirely in your browser using the built-in DOM APIs. Your data never leaves your device.