Skip to main content

AltF Flow recipe

Strip HTML to plain text

To get readable text out of HTML, remove the tags and decode the entities. This recipe deletes script and style blocks and all tags, turning paragraph, heading, list item and line break tags into new lines. It then decodes entities such as &, " and ', trims each line, squeezes extra blank lines so paragraphs stay apart and trims the ends.

  • Free, no sign-up
  • Runs in your browser
  • Nothing uploaded
  • Share recipes as a link

5 steps · runs in your browser · nothing uploaded

Pipeline

  1. Remove tags, scripts and styles, keeping the readable text.

    10 → 16 lines (+6)
  2. HTML unescape

    16 → 16 lines
  3. Remove leading and trailing spaces from each line.

    16 → 16 lines
  4. Keep one between paragraphs

    16 → 12 lines (-4)
  5. Remove spaces and blank lines from the start and end of the whole text.

    12 → 10 lines (-2)

10lines34words342chars

10lines28words187chars

The 5 steps in this recipe

  1. 1

    Strip HTML tags

    Remove tags, scripts and styles, keeping the readable text.

  2. 2

    Encode or decode - HTML unescape

    URL, Base64, HTML entity and JSON string encoding, both directions.

  3. 3

    Trim every line

    Remove leading and trailing spaces from each line.

  4. 4

    Remove empty lines - Keep one between paragraphs

    Delete blank lines, or squeeze runs of blank lines down to one so paragraphs stay apart.

  5. 5

    Trim whitespace

    Remove spaces and blank lines from the start and end of the whole text.

Change any option in the workspace above, switch a step off to compare, or add your own steps. Save it to reuse it, or share the recipe as a link.

Worked example

Before
<style>.promo { color: red; }</style>
<h1>Spring &amp; Summer Menu</h1>
<p>Fresh dishes from our kitchen, served daily.<br>Book a table online.</p>

<ul>
  <li>Tomato &amp; basil soup</li>
  <li>&quot;House&quot; salad with chef&#39;s dressing</li>
</ul>
<script>trackPageView();</script>
<p>Questions? Email hello@example.com&nbsp;today.</p>
After
Spring & Summer Menu

Fresh dishes from our kitchen, served daily.
Book a table online.

Tomato & basil soup

"House" salad with chef's dressing

Questions? Email hello@example.com today.

Why decode after stripping

If entities were decoded first, an escaped &lt;b&gt; in the text would become <b> and then be removed as if it were a tag. Stripping first, then decoding, keeps that text. The step decodes the common named entities (&amp;, &lt;, &gt;, &quot;, &apos;, &nbsp;) and every numeric entity such as &#8211;; rarer named ones like &ndash; are left as written.

Variations

  • Add Straighten smart quotes after decoding if numeric entities produce curly quotes you do not want.
  • Use Remove empty lines in Remove all mode for a compact list with no blank lines.
  • Add Remove line breaks at the end to get the whole text on one line for a meta description draft.

Strip HTML to plain text: questions and answers

Are links kept?

The link text is kept and the URL is removed with the tag. Run the Extract links from HTML recipe on the same source if you need the URLs.

Is this a full HTML parser?

No. It uses pattern matching, which handles normal page and email markup well but can be fooled by unusual code such as > inside attribute values.

What about tables?

Each table row ends a line, but cells in the same row run together. Convert tables with a dedicated tool if layout matters.

More recipes like this

Every step you can add (41)

Clean up

  • Trim whitespace
  • Trim every line
  • Remove empty lines
  • Collapse repeated spaces
  • Remove line breaks
  • Strip HTML tags
  • Straighten smart quotes
  • Remove accents
  • Remove punctuation
  • Remove emoji
  • Remove non-ASCII characters

Change case

  • Change case
  • Make URL slugs

Lines

  • Sort lines
  • Remove duplicate lines
  • Keep only duplicated lines
  • Compare with another list
  • Count repeated lines
  • Reverse line order
  • Shuffle lines
  • Keep a range of lines
  • Truncate long lines
  • Wrap at a width
  • Split into lines
  • Join lines

Find and filter

  • Find and replace
  • Filter lines
  • Remove words or characters

Extract

  • Extract

Data and formats

  • Format JSON
  • Minify JSON
  • CSV to JSON
  • JSON to CSV
  • Lines to JSON array
  • JSON array to lines

Encode and decode

  • Encode or decode

Build output

  • Add prefix / suffix
  • Quote each line
  • Number lines
  • Apply a line template
  • Add timestamp
What each step does, with its options

AltF Flow runs entirely in your browser. Your text is never sent to AltFTool; saved recipes stay in this browser and shared links carry the steps only.