Micru Logo

Strip XML Tags

Remove all XML and HTML tags to extract plain text content. Comments are stripped and CDATA sections are unwrapped to their raw text.

All processing is done locally in your browser. No data is sent to our servers.

What Does Tag Stripping Do?

Tag stripping removes all markup from an XML or HTML document, leaving only the raw text content. Every element's opening and closing tag is deleted; the text nodes between and inside them are kept. The result is a plain, unstructured string representing the document's human-readable content without any markup semantics.

This tool also unwraps CDATA sections (exposing their literal text) and removes comment nodes (<!-- ... -->), which are developer annotations invisible to end users anyway. Consecutive blank lines in the output are collapsed to a maximum of two, preventing vast empty regions from heavily nested documents.

What Gets Removed vs. Kept

Removed

  • All element tags (<p>, <div>, <book>, etc.)
  • All attributes and their values
  • Comment nodes (<!-- ... -->)
  • CDATA delimiters (<![CDATA[ / ]]>)
  • Processing instructions (<?xml ... ?>)

Kept

  • All text node content
  • CDATA section content (unwrapped)
  • Whitespace between text tokens
  • Line structure (collapsed if excessive)

Common Use Cases

Full-Text Search Indexing

Search engines index plain text, not markup. Strip tags from HTML or XML content pages before feeding them to Elasticsearch, Solr, or a vector embedding model to ensure only the textual content is indexed.

Text Analysis & NLP

Natural language processing pipelines (sentiment analysis, entity extraction, summarisation) require clean text as input. Stripping markup prevents the model from treating tag names as language tokens.

Content Migration

When migrating from a CMS that stores content as XML or HTML to one that uses plain text or Markdown, tag stripping is the first step - giving you the raw copy that editors then re-format in the new system.

Email Plain-Text Fallback

HTML email templates must include a plain-text alternative part. Strip the HTML markup to generate the fallback text version quickly, then clean up line breaks for the final text/plain MIME part.

Security Note: Don't Use This as a Sanitiser

Stripping tags is not a substitute for HTML sanitisation in a security context. Simple regex-based tag removal (as opposed to a full DOM parse) can be bypassed by malformed or deliberately crafted markup. To prevent XSS, use a dedicated sanitisation library such as DOMPurify (browser), sanitize-html (Node.js), or bleach (Python) which allow safe tags through rather than blindly removing all markup.