> xml | format | validate <
// Format, minify, or validate XML with line/column errors and pretty-print indentation
Configurable Indentation
Pick 2-space, 4-space, or tab indentation to align the beautified output with your project's existing XML files or pretty-print pipeline.
Handles XML 1.0 Specials
Preserves XML declarations, processing instructions, comments, CDATA blocks, and self-closing tags as defined by the XML 1.0 W3C Recommendation.
Format, Minify, Validate
Switch tabs to pretty-print, normalize to a single line, or check well-formedness with line/column reporting on the first parse error.
// ABOUT XML FORMATTING
How It Works:
The formatter implements a small streaming tokenizer aligned with the XML 1.0 W3C Recommendation. It splits the document into open tags, close tags, self-closing tags, text content, comments, CDATA sections, and processing instructions, tracks nesting depth, and emits each token on its own line indented by the chosen pad. Validation re-runs the tokenizer and surfaces the first malformed token with a 1-based line and column.
Example:
<a><b>1</b><c/></a> -> <a>\n <b>1</b>\n <c/>\n</a>
Common Use Cases:
- >Beautify machine-generated SOAP and RPC payloads for inspection
- >Pretty-print RSS, Atom, and sitemap feeds before debugging
- >Normalize Android, .NET, Spring, and Maven config files for diffs
- >Pre-process two XML documents for canonicalization and comparison
- >Compact XML for embedding in code or wire transport
>> frequently asked questions
Q: Will the XML declaration be preserved?
A: Yes. The declaration and any other processing instructions are tokenized as a single unit and emitted on their own line at the top of the formatted output, exactly as the XML 1.0 W3C Recommendation requires. The encoding pseudo-attribute is left untouched even when reformatting, so downstream parsers continue to read your file correctly.
Q: Are comments and CDATA preserved?
A: Yes. and blocks are tokenized as opaque single units, so their internal whitespace, embedded markup, and content are copied verbatim. This is essential when round-tripping XHTML, build manifests, or scripts embedded in CDATA, where any modification to the inner bytes would break the consuming application or the script semantics.
Q: What if my XML is malformed?
A: The Validate tab reports the first unterminated tag, comment, CDATA, or processing instruction with a 1-based line and column number. Format and Minify also stop on the first parse error. Fix the highlighted region and re-run — the tokenizer is deterministic so the same input always reports the same diagnostic.
Q: Does it canonicalize or validate against an XSD?
A: No. The tool focuses on layout (pretty-print and minify) and well-formedness, not on full XML Canonicalization (C14N) or schema validation. Use a dedicated XSD, Relax NG, or Schematron validator if you need to verify your document against a schema, or use xmllint locally for full XInclude and DTD processing.
Q: Is my XML uploaded to a server?
A: No. The tokenizer, formatter, minifier, and validator all run entirely in your browser using a small vanilla JavaScript implementation. There is no upload, no telemetry, and no server round-trip; the page is fully client-side and works offline once cached.