Skip to main content

Home › Tools › XML Linter

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.

Style linter, not a schema validator. This tool checks how your XML is written (formatting & consistency). To check whether XML is well-formed or conforms to an XSD/DTD schema, use our free online XML validator instead.
Private by design: everything runs locally in your browser with JavaScript. Your XML never leaves this tab — zero network requests.
Choose rules to check (24 available)
Your XML click an issue line number to jump there
Lint results

Press Lint XML to analyze your document.

Auto-fix
Re-indentation always applied.

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 &amp; 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

RuleSeverityWhat it checks
mismatched-tagerrorA closing tag does not match the currently open element.
unclosed-tagerrorAn element was opened but never closed before end of input.
unexpected-closeerrorA closing tag with no matching open tag.
duplicate-attributeerrorThe same attribute name appears twice on one element.
unquoted-attributeerrorAttribute values must be wrapped in quotes.
attr-missing-valueerrorAttribute has a name but no =value.
unescaped-ampersanderrorBare & must be written as &amp; (or another entity).
unclosed-commenterror<!-- without a matching -->.
invalid-tag-starterror< followed by a character that cannot start a tag.
multiple-rootserrorAn XML document must have exactly one root element.
missing-xml-declarationwarningDocument does not start with <?xml version="1.0" ...?>.
declaration-not-firstwarningThe XML declaration must be the very first thing in the document.
missing-encodingwarningThe XML declaration has no encoding attribute.
non-utf8-encodinginfoEncoding declared as something other than UTF-8.
single-quote-attributeinfoAttribute uses single quotes; double quotes are the common convention.
indentationwarningLine indentation does not match the configured indent size/depth.
mixed-tabs-spaceswarningIndentation mixes tab and space characters.
empty-element-not-selfclosedinfo<a></a> could be written as <a/>.
todo-commentinfoComment contains TODO, FIXME, XXX, HACK or BUG.
trailing-whitespaceinfoLine ends with spaces or tabs.
mixed-contentwarningElement contains both text and child elements.
doctype-presentinfoExternal DTDs are never fetched by this offline linter.
line-too-longinfoLine exceeds 200 characters.
empty-documentinfoThere 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