XML Formatter
Format & beautify XML live — configurable indentation, a precise code-frame error for malformed input, and element stats.
About this ToolHow it works, benefits & use casesTap to collapse
Paste minified or messy XML into the XML Formatter and it re-indents the document into a clean, readable tree as you type. A lightweight parser that runs in both the browser and Node walks the markup, validates that every tag is properly closed and nested, and pretty-prints elements, attributes, comments, CDATA sections, and processing instructions. You choose 2-space or 4-space indentation, or switch to tabs. Short elements that wrap a single text value are kept inline (for example a one-line <price>44.95</price>) rather than spread across three lines. If the input is malformed, you get a precise error — the message plus a line and column and a code-frame snippet with a caret pointing at the offending tag — instead of a silent failure. The output can be copied or downloaded as a .xml file, and a footer reports how many elements were found. It is free and processes everything locally.
How to Use
- 1Paste your XML into the input panel, or click "Load example" to load a sample catalog document.
- 2Pick your indentation in Options: 2 spaces or 4 spaces, or tick "Use tabs".
- 3Click Format XML — the formatted tree updates live as you type and adjust options.
- 4If the XML is invalid, read the inline error showing the message, line, column, and a caret pointing at the problem tag.
- 5Copy the formatted XML or download it as a .xml file; the footer shows the element count.
Key Benefits
- Re-indents minified or single-line XML into a readable nested tree
- Choice of 2-space, 4-space, or tab indentation
- Keeps single-value elements inline instead of splitting them across lines
- Validates tag nesting and flags mismatched or unclosed tags
- Precise line:column code-frame error pinpoints malformed markup
- Handles comments, CDATA, processing instructions, and the XML declaration
- Element count and one-click copy or .xml download; runs fully in-browser
Common Use Cases
- Making a compressed API or config XML response human-readable for debugging
- Cleaning up hand-edited RSS, sitemap, or SVG markup before committing
- Tracking down a mismatched or unclosed tag in a broken document
- Normalizing indentation across XML files to a team standard
- Inspecting SOAP or build-tool XML payloads during integration work
Options
0 characters · live
Paste XML above to format it live.
Was this tool helpful?
Share Your Experience
Help others discover this tool!
Related tools
- API Response FormatterFormat and beautify API responses
- Sitemap GeneratorGenerate XML sitemaps for SEO
- Code Block FormatterFormat code blocks for Markdown
- Sitemap Priority CalculatorPaste a list of URLs and get a complete XML sitemap with priorities from a transparent, tunable model — each URL auto-classified by type & depth, with a per-row score breakdown and priority distribution analysis
- Stack Trace FormatterBeautify and analyze JavaScript stack traces
- File Size FormatterConvert any file size across decimal (KB/MB/GB) and binary (KiB/MiB/GiB) units side by side, with exact byte counts and a download-time estimator across 56k → fiber connection speeds
Yes. Before formatting, it tokenizes the document and checks that every opening tag has a matching close and that tags are nested correctly. If a tag is unclosed, mismatched, or unexpectedly closed, formatting stops and you get an error describing the problem rather than malformed output.
You can format with 2 spaces or 4 spaces per level, or enable "Use tabs" to indent with tab characters instead. The preview re-renders immediately when you change the setting.

