The job
What the Grok strip HTML tool fits into
It sits at the point where markup has to become words. A page source you want the copy out of, an email template, a database column that stored formatted text, an export that wrapped every paragraph in tags.
The work is four rules applied in order, running in the page. Script blocks go with their contents, style blocks go with their contents, everything between angle brackets goes, and four entities are turned back into characters. Nothing is uploaded and nothing is stored.
Afterwards the tool reports how many characters were removed or changed. On a page source that number will be large, and it is a length difference rather than a count of tags.
The output
What you get back, and what you lose
Worth knowing before you paste, because a tag strip is not a conversion and several things you might expect to survive do not.
- Kept
- All text between tags, and all whitespace that was already in your source. Blank lines are preserved exactly, so three in a row stay three in a row.
- Kept
- Anchor text. The words inside a link survive, which is usually what you wanted from the copy.
- Lost
- Link addresses. The href attribute goes with the tag, so a page full of links comes back as a page full of unlinked phrases.
- Lost
- Structure. Headings, lists, bold and emphasis all become undifferentiated text with no marker of what they were.
- Lost
- Break and paragraph tags, without leaving a newline behind. If your source was minified onto one line, the output is one line.
- Removed entirely
- Script and style blocks, contents included. Not every stripper does this, and one that publishes its code says openly that it leaves the JavaScript in place.
The routine
How to strip HTML from a page source in three steps
Three steps, with a verification pass that is not optional if the markup came from a machine.
- Step 1
- Paste the whole source. There is no character cap here, so you do not need to cut a page into pieces the way a twenty thousand character limit would force you to.
- Step 2
- Press Strip HTML and copy the result out of the right-hand pane. Clear empties both panes afterwards.
- Step 3
- Scan the output for leftovers. A stray quote mark, a fragment of an attribute or a closing comment marker means the source had a greater-than sign somewhere a pattern match could not see past.
The detail
Which entities come back as characters
Strippers disagree sharply here. One decodes twenty or more entities including numeric ones. One deletes them outright and points you at a separate decoder. One leaves every entity untouched. This tool decodes four and passes the rest through unchanged.
The four are the non-breaking space, which becomes an ordinary space, the ampersand, and the less-than and greater-than entities, which become real angle brackets. That last pair has a consequence: markup that was safely escaped in your source arrives un-escaped in the output as literal text.
Everything else is untouched and we tested it. The quote entity, the numeric apostrophe and the copyright entity all survive exactly as typed. If your text needs those resolved, that is a second step this tool does not perform.
The straight answer
Can the strip HTML tool sanitize untrusted markup?
No. Treat that as a hard no rather than a caution. The most technically candid stripper in this category says the same of itself, and the reasoning applies identically here.
The specific hazard is the entity step. Escaped markup arriving as text comes out of this tool with genuine angle brackets around it, which is the reverse of what a sanitizer does. Safe input becomes markup-shaped output.
Use this when the destination is a text file, a word counter, a spreadsheet cell or a draft. Use a real sanitizer when the destination renders HTML and the input is not yours.
The failure mode
The cases pattern matching cannot handle
This tool matches tags by pattern rather than building a document tree, which is what every tool in this category does. Each competitor that publishes its mechanism concedes the same limit, one of them using a comparison expression as the example that gets misread as a tag.
We tested ours rather than describing the idea. An attribute value containing a greater-than sign ends the match early, so part of the attribute survives into the output. An HTML comment containing a greater-than sign leaves its closing marker behind.
Hand-written markup rarely trips this. Generated markup, minified templates and anything with inline comparison operators trips it more often, which is why step three exists and why the page does not promise robustness it cannot deliver.
The choice
When a tag strip is the wrong operation
If you need the structure kept, this is not it. Converting headings and lists into Markdown preserves what a strip discards, and that is a separate route on this site rather than a mode on this one.
If you need only the entities resolved and the markup left alone, this is also not it, because tags are removed unconditionally and there is no way to keep them.
If you need whitespace tidied after the strip, that is another route again. This tool leaves spacing exactly as it found it, which is deliberate: a strip that also reflows text makes two changes when you asked for one.
The users
Who uses the Grok strip HTML tool, and when
Content people recovering copy from a system that gave it back wrapped in markup. The words are correct and everything around them is noise.
Developers run it on a field that stored HTML it should not have, or on a fixture they need as plain text. Editors run it before a word count, because a counter fed raw markup counts tag names as words. Support teams run it on email source to read what a customer actually received.
The pattern that disappoints is expecting a document back. What returns is the text that was in the document, in the order it appeared, with nothing to indicate which part was a heading and which was a caption.