XML Highlighter
FV-56Paste XML to see tags, attributes, values, comments and CDATA in their own colors. As written keeps your exact text; the indent layouts re-indent it first. The status line says whether the XML is well-formed.
Runs in your browser. Nothing is uploaded.
XML
Highlighted XML
How to use it
- Paste your XML, or open an .xml file.
- Keep As written, or pick an indent of 2 spaces, 4 spaces or tabs.
- Choose the Light or Dark theme and line numbers if you need them.
- Read the status line for a well-formed check, then press Copy HTML or Download.
As written or re-indented
As written colors your XML exactly as typed, even when it is broken, so you can highlight a fragment or a file with an error in it. The indent layouts rebuild the indentation first. That needs well-formed XML, and runs of spaces inside text are collapsed. CDATA sections, comments and processing instructions are kept as they are.
The well-formed check
Whatever layout you pick, the tool also parses the XML and reports the result in the status line: either Well-formed XML or the first problem with its line, such as a tag that is never closed. It checks structure only. It does not validate against a schema or DTD, and a DOCTYPE is shown but never loaded.
Questions people ask
Does the XML highlighter change my XML?
Not with As written, which is the default: the colored output has the same characters as your input. The indent layouts change whitespace between elements and collapse repeated spaces in text, but they keep names, attributes, values and CDATA.
Can it highlight XML that is not well-formed?
Yes, with As written. The tokenizer colors whatever it can and the status line names the first structural problem. The indent layouts need well-formed XML, because they have to know where each element starts and ends.
Are entities such as & decoded?
No. Entities and character references are colored as entities and shown as typed, so & stays & in the output. That keeps the highlighted code identical to the source you would put in a file.
How do I use the colored XML on a web page?
Press Copy HTML and paste into an editor that accepts HTML, or Download to save it as an .html file. Each colored token is a span with an inline style inside a pre block, so it needs no extra CSS.
Is my XML uploaded?
No. Tokenizing, re-indenting and the well-formed check all run in your browser tab. No part of the XML is sent to a server, and the HTML you download is created on your device.
About this tool
As written colors your XML exactly as typed, even when it is broken, and the status line says whether it is well-formed and where the first problem is. The indent layouts re-indent the elements first, which needs well-formed XML and collapses runs of spaces inside text; CDATA, comments and processing instructions are kept as they are. Entities such as & are colored but not decoded, and a DOCTYPE is shown but never loaded. Copy HTML and Download give a <pre> block with inline colors.