FORMATFYCOM formátovač · validátor · minifikátor About

What's new

XML Formatter & Validator

Format and validate XML online. Errors explained in plain English and fixed in one click. Free, no ads, runs in your browser.

Input

Output


      

How to format and validate XML

The formatter indents one-line or messy XML, checks that it is well-formed, and when it finds an error it explains it in plain English, points to the exact spot and offers a fix. It keeps the XML declaration, DOCTYPE, CDATA, namespaces and comments.

  1. Paste your XML

    Copy XML from an API, an export or a config file, drop a file (SVG, XSD, WSDL too), or click Sample.

  2. Format, minify, validate

    Indent with 2 or 4 spaces or tabs. Ctrl+Enter formats, Ctrl+Shift+Enter minifies, Ctrl+G jumps to a line.

  3. Fix errors in one click

    Each error shows the line and column with an arrow and a fix button. “Fix everything” applies all safe fixes at once.

XML errors the formatter detects and fixes

The most common reasons XML won’t load — with the messages parsers print. If you got one of these, paste your XML above.

Unquoted attribute value

Fine in HTML, but in XML every attribute value must be quoted.

<book id=bk101>→<book id="bk101">
Typical messages: AttValue: " or ' expected (libxml2 (Chrome, PHP)), not well-formed (invalid token) (Python (expat))
✓ fixed automatically

Bare & in text

& starts an entity; on its own it must be written as &amp;.

Tom & Jerry→Tom &amp; Jerry
Typical messages: xmlParseEntityRef: no name (libxml2 (Chrome, PHP)), not well-formed (invalid token) (Python (expat))
✓ fixed automatically

Bare < in text

< starts a tag; in text write &lt;.

<a>1 < 2</a>→<a>1 &lt; 2</a>
Typical messages: StartTag: invalid element name (libxml2 (Chrome, PHP))
✓ fixed automatically

Mismatched tags

An element is closed by a different tag than it was opened with — a missing end tag or a typo.

<a><b></a>→<a><b></b></a>
Typical messages: Opening and ending tag mismatch: b line 1 and a (libxml2 (Chrome, PHP)), mismatched tag (Python (expat))
✓ fix offered

HTML entities (&nbsp;, &copy;…)

XML knows only 5 entities; others must be numeric.

price&nbsp;100→price&#160;100
Typical messages: Entity 'nbsp' not defined (libxml2 (Chrome, PHP)), undefined entity (Python (expat))
✓ fixed automatically

Multiple root elements

XML may have only one root — typically concatenated files or a fragment of a larger document.

<a/><b/>→<root><a/><b/></root>
Typical messages: Extra content at the end of the document (libxml2 (Chrome, PHP)), junk after document element (Python (expat))
✓ fix offered

Undefined namespace prefix

An element uses the prefix x: but xmlns:x is not declared.

<a><x:b/></a>→<a xmlns:x="urn:x"><x:b/></a>
Typical messages: Namespace prefix x on b is not defined (libxml2 (Chrome, PHP)), unbound prefix (Python (expat))
✓ fixed automatically

Unclosed element (truncated file)

The document ends before all elements are closed.

<a><b>→<a><b></b></a>
Typical messages: Premature end of data in tag b line 1 (libxml2 (Chrome, PHP)), no element found (Python (expat))
✓ fix offered

…and more: attributes without a value (<input checked>), duplicate attributes, whitespace before <?xml ?>, “--” in comments, control characters, missing space between attributes.

FAQ

What does “well-formed” mean?

Correctly structured XML: matching tags, quoted attributes, a single root element and escaped special characters. Validation against a schema (XSD) is not performed.

Why won’t my XML load when it looks fine in a browser?

Browsers forgive HTML mistakes, XML parsers don’t — a single & or an unquoted attribute is enough. The formatter points to the exact spot.

Does it keep comments and CDATA?

Yes. Comments can be dropped with an option; CDATA, the declaration, DOCTYPE and namespaces are kept.

Is it free, without sign-up?

Yes. No sign-up, no ads and no size limit — the only limit is your computer.

Is my data sent to a server?

No. Everything runs in your browser and the data you paste never leaves it — fine even for data with tokens or personal information.

Related tools