consolelog.tools

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 cases

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

  1. 1Paste your XML into the input panel, or click "Load example" to load a sample catalog document.
  2. 2Pick your indentation in Options: 2 spaces or 4 spaces, or tick "Use tabs".
  3. 3Click Format XML — the formatted tree updates live as you type and adjust options.
  4. 4If the XML is invalid, read the inline error showing the message, line, column, and a caret pointing at the problem tag.
  5. 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