Free Online XML Linter
Paste your XML and get a line-by-line style report: mismatched tags, duplicate attributes, bad indentation, missing declarations and more — then fix issues automatically with a reviewable diff. No signup, no uploads.
Choose rules to check (24 available)
Press Lint XML to analyze your document.
Press Auto-fix to preview the diff here.
Worked examples
Each example loads into the editor with one click. The issue counts below are computed live by the linter engine itself.
Mismatched tags
2 error(s), 3 warning(s), 0 info note(s) — computed by the linter engine
<catalog> <book> </catalog> </book>
Duplicate attribute
1 error(s), 0 warning(s), 0 info note(s) — computed by the linter engine
<?xml version="1.0" encoding="UTF-8"?> <item id="1" id="2"/>
Unquoted attribute value
1 error(s), 0 warning(s), 0 info note(s) — computed by the linter engine
<?xml version="1.0" encoding="UTF-8"?> <item price=9.99/>
Missing declaration + bad indentation
0 error(s), 4 warning(s), 0 info note(s) — computed by the linter engine
<root> <child name="x"> <leaf/> </child> </root>
Unescaped ampersand
1 error(s), 0 warning(s), 0 info note(s) — computed by the linter engine
<?xml version="1.0" encoding="UTF-8"?> <note>fish & chips & more</note>
TODO comment, single quotes, empty element
0 error(s), 0 warning(s), 3 info note(s) — computed by the linter engine
<?xml version="1.0" encoding="UTF-8"?> <!-- TODO: remove debug flag --> <config debug='true'></config>
Mixed content
0 error(s), 1 warning(s), 0 info note(s) — computed by the linter engine
<?xml version="1.0" encoding="UTF-8"?> <para>Some text <b>bold</b> more text</para>
Clean document (zero issues)
0 error(s), 0 warning(s), 0 info note(s) — computed by the linter engine
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<book id="b1">
<title>Example</title>
</book>
</catalog>
Rules reference
| Rule | Severity | What it checks |
|---|---|---|
mismatched-tag | error | A closing tag does not match the currently open element. |
unclosed-tag | error | An element was opened but never closed before end of input. |
unexpected-close | error | A closing tag with no matching open tag. |
duplicate-attribute | error | The same attribute name appears twice on one element. |
unquoted-attribute | error | Attribute values must be wrapped in quotes. |
attr-missing-value | error | Attribute has a name but no =value. |
unescaped-ampersand | error | Bare & must be written as & (or another entity). |
unclosed-comment | error | <!-- without a matching -->. |
invalid-tag-start | error | < followed by a character that cannot start a tag. |
multiple-roots | error | An XML document must have exactly one root element. |
missing-xml-declaration | warning | Document does not start with <?xml version="1.0" ...?>. |
declaration-not-first | warning | The XML declaration must be the very first thing in the document. |
missing-encoding | warning | The XML declaration has no encoding attribute. |
non-utf8-encoding | info | Encoding declared as something other than UTF-8. |
single-quote-attribute | info | Attribute uses single quotes; double quotes are the common convention. |
indentation | warning | Line indentation does not match the configured indent size/depth. |
mixed-tabs-spaces | warning | Indentation mixes tab and space characters. |
empty-element-not-selfclosed | info | <a></a> could be written as <a/>. |
todo-comment | info | Comment contains TODO, FIXME, XXX, HACK or BUG. |
trailing-whitespace | info | Line ends with spaces or tabs. |
mixed-content | warning | Element contains both text and child elements. |
doctype-present | info | External DTDs are never fetched by this offline linter. |
line-too-long | info | Line exceeds 200 characters. |
empty-document | info | There is nothing to lint. |
Frequently asked questions
What is the difference between an XML linter and an XML validator?
An XML validator checks correctness: is the document well-formed, and does it conform to an XSD schema or DTD. An XML linter checks style and consistency: indentation, attribute quoting, duplicate attributes, self-closing tags, encoding declarations and leftover TODO comments. This page is the linter. If you need well-formedness or schema validation instead, use our free XML validator at https://nrtechstudio.com/tools/xml-validator/.
Which rules does the XML linter check?
24 rules across three severities. Errors: mismatched tags, unclosed tags, unexpected closing tags, duplicate attributes, unquoted attributes, attributes without values, unescaped ampersands, unclosed comments, invalid tag starts and multiple root elements. Warnings: missing XML declaration, declaration not on line one, missing encoding, inconsistent indentation, mixed tabs and spaces, and mixed content. Info-level notes: non-UTF-8 encodings, single-quoted attributes, empty elements not self-closed, TODO-style comments, trailing whitespace, DOCTYPE presence and long lines.
Is my XML uploaded to a server?
No. The linter is 100% client-side JavaScript: tokenizing, rule checks, auto-fix and diff all run locally in your browser tab. There are zero network requests, no signup and no file-size gate imposed by a server.
Can the linter fix my XML automatically?
Yes. Tick the fixes you want — add a missing XML declaration, re-indent the document, normalize single quotes to double quotes, collapse empty elements to self-closing tags, trim trailing whitespace — then click Auto-fix. The tool shows a line-by-line diff so you can review every change before copying the result.
Why does the linter not use the browser built-in XML parser?
The built-in DOMParser stops at the first fatal error and reports little about style. This linter uses its own hand-rolled tokenizer, so it can keep going after an error, report every issue with an exact line number, and check style rules (indentation, quoting, comments) that a validating parser never looks at.
What are the limitations of this XML linter?
It is a style linter, not a validator: it does not check your document against an XSD schema or DTD, and it never fetches external DTDs. Namespace prefixes are not resolved against declarations. On severely broken documents the tree recovery is best-effort, so fix fatal syntax errors first and re-lint.
When should I use the XML validator instead of the linter?
Use the XML validator at https://nrtechstudio.com/tools/xml-validator/ when you must prove a document is well-formed or conforms to a contract (XSD/DTD) — for example before sending XML to an API or a business partner. Use this linter when the document already parses but you want it clean, consistent and review-ready.
Related tools
Free tool by NRTechStudio