XML Formatter, Minifier & Validator

// Format, minify, or validate XML with line/column errors and pretty-print indentation

[INDENT]

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.

[ROBUST]

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.

[MODES]

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.

// OTHER LANGUAGES

XML Formatter, Minifier & Validator — Base64.sh

XML Formatter, Minifier & Validator | Free Online XML Beautifier

Free online XML formatter, minifier, and validator. Beautify or compact XML in your browser, no upload, client-side, with line/column error reporting.

Share:

References

How we make sure

We check this tool with the automated test suites linked below. Example checks are shown in their original language.

Verification method
Compare formatted fixtures and check preservation of text leaves, mappings/sequences and nesting.
Comparison reference
Explicit output fixtures and structural assertions, without a second full formatter.
Verification scope
These samples and boundaries do not prove correctness for every input.
Test source and cases (select a file to read it)
  • xml-formatter.test.js
    • formatting a text leaf keeps its opening and closing tags
    • formatting sibling and nested text leaves does not replace their opening tags

These checks cover the listed examples and boundaries, not every possible input. Round trips and checks using the same library are not independent verification.