Home › Developer Tools › XML Validator

XML Validator

Paste XML or open a file to check that it is well-formed. The first parser error is pinned to its exact line and column with a plain-English fix, a second scan lists other problems, and valid XML is pretty-printed for you.

Last updated:

XML input
Ln 1, Col 10 B
Advertisement
Advertisement

How to use the XML Validator

  1. Paste your XML into the editor, open a file, or drag one onto the editor. It is checked automatically.
  2. Read the result. Green means well-formed. Red shows the line, column, the parser's message and what it means.
  3. Press Go to error to jump to the problem, or click any item under Other problems found.
  4. Fix and re-check. The check reruns as you type; press Check XML or Ctrl + Enter if live checking is off.
  5. Copy or download the pretty-printed XML, or press Format input to replace your text with it.

Common XML errors and how to fix them

Parser message (Chrome/Edge)BrokenFixed
Opening and ending tag mismatch<price>24</Price><price>24</price>
xmlParseEntityRef: no name<name>Salt & Pepper</name><name>Salt &amp; Pepper</name>
AttValue: " or ' expected<item id=7><item id="7">
Extra content at the end of the document<a/><b/><root><a/><b/></root>
StartTag: invalid element name<if>x < 5</if><if>x &lt; 5</if>
Entity 'nbsp' not defined<p>10&nbsp;km</p><p>10&#160;km</p>
Attribute x redefined<img src="a" src="b"/><img src="a"/>
Namespace prefix … is not defined<media:thumb/><media:thumb xmlns:media="…"/>
XML declaration allowed only at the startblank line before <?xml …?><?xml …?> as the first characters
Premature end of data in tag<list><li>1</li><list><li>1</li></list>

Firefox words the same errors differently, for example "mismatched tag", "not well-formed", "junk after document element" or "undefined entity". The hint under the message explains each of them in plain English.

The well-formedness rules in short

  • One root element contains everything else. Comments, processing instructions and a DOCTYPE may appear before or after it, but no other elements or text.
  • Tags nest properly. Every <tag> has a matching </tag>, or is written as an empty element <tag/>. The last opened element closes first.
  • Names are case-sensitive and must start with a letter or underscore. <Item> and <item> are different elements; <2nd> is not a valid name.
  • Attribute values are always quoted with " or ', every attribute has a value, and a name appears only once per element.
  • Escape the special characters. In text write & as &amp; and < as &lt;. Inside attribute values also escape the quote character you used. Alternatively wrap text in <![CDATA[ … ]]>.
  • The XML declaration <?xml version="1.0" encoding="UTF-8"?> is optional, but when present it must be the very first thing in the file.

Tips for tracking down errors

Fix the first reported error and check again: one missing closing tag can make everything after it look wrong. When the reported line looks fine, look a few lines above it, because the parser only stops when the mistake becomes impossible to ignore. Files exported from spreadsheets or databases often break on unescaped ampersands in company names and URLs, while files edited by hand usually break on mismatched case or a forgotten closing tag.

Frequently asked questions

What does well-formed XML mean?

Well-formed XML follows the basic syntax rules of the XML 1.0 specification: exactly one root element, every start tag closed by a matching end tag in the right order, attribute values in quotes, no repeated attribute on one element, and the characters & and < escaped in text. A document that breaks any of these rules is not XML at all, and every XML parser must reject it.

Is well-formed the same as valid?

No. Well-formed means the syntax is correct. Valid means it also follows a DTD or XML Schema (XSD) that defines which elements and attributes are allowed. This tool checks well-formedness, which is what every parser requires; it reports when a DTD or XSD is referenced but does not download or apply it.

Why does it say Opening and ending tag mismatch?

A closing tag does not match the element that is currently open. Common causes are a missing closing tag earlier in the file, tags closed in the wrong order, such as <b><i></b></i>, or a case difference, because XML names are case-sensitive: <Price> and </price> do not match.

How do I fix an error about & or EntityRef?

A bare ampersand is not allowed in XML text or attribute values. Write it as &amp;, for example ?a=1&amp;b=2 in a URL. Only &amp;, &lt;, &gt;, &quot; and &apos; are predefined; HTML entities such as &nbsp; must be written as numeric references like &#160; unless a DTD defines them.

Why is the error reported on a later line than the real mistake?

A parser only notices a problem when it reads something that cannot be correct. A tag left open on line 5 may only be detected when the parent closes on line 40. Check the list of other problems and the lines just above the reported position.

Is my XML uploaded to a server?

No. The XML is parsed by the DOMParser built into your browser and all checks run locally on your device. Nothing is sent anywhere, so it is safe for configuration files and private data.

Can it check SVG, RSS, sitemap or KML files?

Yes. These formats are all XML, so they must be well-formed. Open the file or paste its content to check it. The tool checks syntax, not format-specific rules such as required RSS channel elements.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

XML FormatterBeautify, validate and minify XML with a collapsible tree view.XML to JSONConvert XML to JSON with validation.XML MinifierMinify and validate XML: strip whitespace and comments, keep CDATA, see the size savings.JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.SAML DecoderDecode SAMLRequest and SAMLResponse messages to readable XML, attributes and validity times.JSON to Excel ConverterTurn JSON into a styled .xlsx spreadsheet; nested arrays become their own linked sheets.JSON to CSVConvert JSON data to CSV for spreadsheets.CSV to JSONConvert CSV data to JSON with live preview.Excel to CSVConvert XLSX spreadsheets to CSV.CSV ViewerOpen a CSV or TSV file as a sortable, filterable table.Excel Viewer (XLSX / XLS)Open XLSX, XLS and ODS spreadsheets in your browser without Excel.Line Ending ConverterConvert text and files between CRLF, LF and CR line endings.Markdown to HTMLConvert Markdown to clean HTML with a live editor.Text Encoding ConverterDetect and convert text file encodings like UTF-8, UTF-16 and Latin-1.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.Morse Code TranslatorTranslate text to Morse code and back, then play it as sound or a blinking light, or save a WAV.HTML Table GeneratorBuild HTML tables in an editable grid with styles, header rows, CSV import and live preview.Hex to Text ConverterConvert hex to text and text to hex with UTF-8 support and space, 0x, \x or comma formats.JSON to XML ConverterConvert JSON to well-formed XML with attributes, arrays and pretty print.JSON to YAML ConverterConvert JSON to clean YAML as you type, with indent, quoting and sort options.YAML to JSON ConverterConvert YAML to pretty or minified JSON, with errors pinned to the exact line.HTML to Markdown ConverterTurn HTML or pasted rich text into clean Markdown with tables and live preview.Markdown Table GeneratorBuild Markdown tables in a grid or paste from Excel/CSV, with alignment and preview.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.JSON CompareCompare two JSON documents and see every added, removed and changed path.Hex to DecimalConvert hex to decimal instantly with steps and signed mode.Decimal to HexConvert decimal to hex instantly with steps and signed mode.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Decimal to BinaryConvert decimal to binary instantly with steps and signed mode.Two's Complement CalculatorDecimal to two's complement binary and back for 4-64 bits, with invert-and-add-1 steps.XML to CSV ConverterConvert XML to CSV: detects repeating records, flattens nested data, pick your columns.CSV to XML ConverterConvert CSV to well-formed XML with custom root and row names, escaping and pretty print.TOML to JSON ConverterConvert TOML to JSON and JSON to TOML with a full v1.0 parser and clear error lines.JSON to Go StructTurn JSON into Go structs with inferred types, nested structs and json tags.Query CSV with SQLRun SQL on CSV, Excel, JSON and Parquet files in your browser with DuckDB. Join and export.Online Serial MonitorTalk to Arduino, ESP32 and USB serial devices in your browser: log, send, plot and save.Split Excel FileSplit an Excel sheet into several files by row count or by each value in a column, as ZIP.SQL Create Table GeneratorDefine columns, keys, defaults and indexes; get CREATE TABLE SQL for MySQL, Postgres and more.SQL IN Clause GeneratorTurn a pasted list into a SQL IN ('a','b') clause with quoting, dedupe and 1,000-item chunks.SQL Online CompilerRun SQL queries online on SQLite with sample databases, a result grid, CSV export and .db save.SQL to ER DiagramPaste CREATE TABLE statements and get an entity-relationship diagram with keys and links.XML to XSD GeneratorGenerate an XML Schema (XSD) from sample XML: types, occurrences, attributes and namespaces.Wildcard Mask CalculatorConvert a subnet mask or CIDR to a wildcard mask for ACLs and OSPF, with range and binary.CSV to VCF ConverterConvert a contacts CSV into a vCard (.vcf) file, mapping columns to name, phone, email and more.CSV to YAML ConverterConvert CSV rows to a YAML list of mappings with type inference and delimiter detection.Endianness ConverterSwap byte order of 16, 32 and 64-bit hex values and see big- and little-endian integers and floats.Excel to SQL ConverterTurn an Excel sheet into CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.Excel to VCF ConverterTurn an Excel contact list into a vCard .vcf file for iPhone, Android, Google or Outlook.File to C ArrayConvert any file into a C or C++ byte array header, like xxd -i, with const and PROGMEM options.Image to C ArrayConvert images to monochrome, RGB565 or RGB888 C arrays for OLED, LCD and TFT displays.JSON Merge ToolDeep-merge two or more JSON objects with array concat, replace or union and a conflict rule.JSONL to CSV ConverterConvert JSON Lines / NDJSON to CSV with flattened columns; streams large files locally.PHP Unserialize OnlineDecode PHP serialize() strings to JSON, a tree or print_r, and serialize JSON back to PHP.SQL Dialect ConverterTranslate SQL between MySQL, PostgreSQL, SQLite, SQL Server, Oracle, BigQuery and more.TSV to JSON ConverterTurn tab-separated data pasted from Excel or Sheets into a JSON array or keyed object.XLS to XLSX ConverterConvert old Excel 97-2003 .xls workbooks to modern .xlsx files in your browser, several at once.XML to Excel ConverterTurn repeating XML elements into an .xlsx spreadsheet with attributes and nested data as columns.XSD to XML Sample GeneratorGenerate a sample XML document from an XSD schema, with types, attributes and namespaces.YAML to CSV ConverterTurn a YAML list of objects into CSV with dot-notation columns, custom column order and download.DOCX to Markdown ConverterConvert Word .docx to clean Markdown with headings, lists, tables, links and images in a ZIP.ES6 to ES5 ConverterTranspile modern JavaScript (ES2015+) to ES5 with Babel: targets, module format and loose mode.JavaScript Object to JSONTurn JS object literals and Python dicts into valid JSON: quotes keys, fixes commas and values.JSON Graph VisualizerSee JSON as an interactive node graph with zoom, collapse and search; export PNG or SVG.KML ViewerOpen KML and KMZ files on an interactive map: placemarks, paths, polygons, folders, export.
See all 129 Data & File Format Converters →