CruxDevCruxDev Tools Prompts
dev Utility • Zero-Server Privacy • 100% Client-Side

XML Formatter & Validator

Beautify, minify, and validate XML documents. Highlights malformed tags and syntax errors.

Overview

Beautifies or minifies XML in the browser using the browser's own XML parser — so validation is genuine well-formedness checking, not a regex guess — with copy and download of the result.

How It Works

Paste XML; the toggle chooses Beautify (2-space indentation) or Minify (whitespace between tags collapsed). Output updates live, a red border plus the parser's first error line appears when the document is malformed, and Copy and Download (output.xml) become available once there is output.

Step-by-Step Usage Guide

  1. Paste the XML document into the left pane.
  2. Choose Beautify or Minify with the toggle.
  3. Fix any red error line — it quotes the browser's own parser message.
  4. Copy the result or download it as output.xml.

Technical Specifications & Standards

Parsing uses DOMParser with the application/xml type, and the tool inspects the parsererror node — the browser's actual complaint — surfacing its first line. Minify is a conservative pass that removes whitespace between tags only, never inside text nodes (an empty element such as <a></a> is written as <a/>). Beautify walks the parsed document and indents by depth with a fixed 2-space unit: elements that contain only child elements get one child per line, while any element that holds text or CDATA (text-only or mixed content) is written out on one line exactly as it is, so text is never re-indented or altered. Start tags are rebuilt from each element's own attributes, so inherited xmlns declarations are not repeated on every child, and a leading <?xml ...?> declaration is kept.

Targeted Use Cases

  • Pretty-printing an XML config, sitemap, or RSS feed before reading or diffing it.
  • Shrinking a machine-generated XML file for transport or embedding.
  • Checking whether an XML file is well-formed at all before feeding it to a stricter tool.
  • Normalising indentation across files so version-control diffs show real changes.

Notes & Gotchas

  • Validation is well-formedness only — there is no XSD or DTD schema validation here.
  • Beautify's 2-space indentation is fixed; there is no indent-size or attribute-wrapping option.
  • Text nodes are preserved: elements with mixed content stay on one line exactly as written, so they can look long or unindented after formatting.
  • Only the parser's first error line is shown; fix it and re-run to reveal the next problem, if any.

Frequently Asked Questions

Does it validate against an XSD schema?

No. It checks well-formedness via the browser's XML parser — structure and syntax, not schema conformance.

What exactly does Minify remove?

Whitespace between tags. Text inside elements is never touched, so character data survives byte-for-byte.

Where does the download go?

The formatted or minified output downloads as output.xml straight from your browser — nothing is uploaded.

Why is my error message short?

Only the first line of the browser's parser error is shown; fix that problem and the next error, if any, appears on the next pass.