Stripping HTML: Two Modes Differ on Line Breaks

Open Tool Strip HTML Tags

Parse into a tree, then take the text

In page source, what a reader sees is text, and what nobody sees is tags nested layer on layer. Stripping correctly means parsing into a document tree and taking text nodes, not deleting angle brackets with search and replace. The first approach knows a paragraph from a script; the second leaves code as body copy and drags attribute values along. The tool has two modes: plain text flattens every space for summaries, search and word counts, while line-preserving mode breaks at block elements for reading and proofing.

Steps

  1. Paste the page source, or save it to a file and copy wholesale.
  2. Pick plain text or line-preserving mode for the job at hand.
  3. Run it and check the opening lines for leftover script or style.
  4. Search for entity signs and confirm ampersand codes became characters.
  5. Copy the result, and re-paragraph the plain-text variant by hand.
  6. Reset for the next page.

Block elements, entities, tables

Line breaks come from block elements: paragraphs, divisions, list items and break tags each end a line, while inline tags must not, or one sentence splits into fragments. Content inside script and style tags is dropped entirely, being unreadable output. Entities need decoding, and an unreplaced space entity becomes a placeholder symbol. Tables are hardest, since cells need tabs or spaces between them or the whole grid collapses into one line with numbers fused together. Flattening kills stray blank lines but also paragraph boundaries, so long text needs a second pass.

Common mistakes

Regex-stripping brackets leaves script code as prose. Undecoded entities show as literal placeholders. Plain mode fuses two paragraphs into one sentence. Table cells collapse into a single line. Line-preserving mode emits dozens of blank lines. And navigation plus footer get harvested as body copy.

Where stripping is not extraction

Tags come off, but navigation, ads and copyright lines stay, so real article extraction needs another approach. Script-rendered content never appears in source. Malformed markup gives unpredictable tolerance, so important text is verified in a browser. Anything preserving layout loses styling by definition. And output used as final copy always gets a human read.

⏫︎