Unclosed XML CDATA Section – Fix Missing ]]> Errors

Local only

A CDATA section that starts with <![CDATA[ must end with ]]> before XML markup can resume.

27 chars · 1 line

Waiting for input

Loading XML parser…

XML CDATA troubleshooting

How to fix an unclosed CDATA section in XML

The sample opens CDATA before 1 < 2 but never emits ]]> before the root closing tag. Once CDATA starts, markup-like characters are treated as text until the exact CDATA terminator appears. This tool is free to use. No account or payment is required.

Last updated

What you can do here

  • XML well-formedness validation
  • Broken XML example preloaded
  • Corrected XML comparison
  • .xml file import
  • Browser parser feedback
  • Browser-local processing

Steps

  1. Locate the <![CDATA[ opener nearest the parser failure.
  2. Identify the intended end of raw text content.
  3. Insert ]]> before the following XML markup and validate the complete document again.

CDATA changes how markup characters are interpreted

Inside CDATA, characters such as < and & can appear as text without normal escaping. That special parsing mode continues until ]]> is found, so a missing terminator can make later closing tags disappear into text from the parser's point of view.

CDATA cannot contain its own terminator literally

If the source text itself contains ]]>, split the content into multiple sections or serialize the data another way rather than nesting or escaping the terminator inside one CDATA section.

Unclosed XML CDATA example

Close CDATA before the root closing tag.

Invalid XML

<root><![CDATA[1 < 2</root>

Corrected XML

<root><![CDATA[1 < 2]]></root>

Common questions

Frequently asked questions

How does an XML CDATA section end?

CDATA starts with <![CDATA[ and ends with ]]>.

Can CDATA contain less-than signs without escaping?

Yes. That is one common reason to use CDATA for text-like payloads.

Can CDATA sections be nested?

No. CDATA sections do not nest.

Debugging a specific XML issue? Browse XML troubleshooting.