Home » Blog » Document Joiner » How to Merge HTML Files Into Text: One TXT File

How to Merge HTML Files Into Text: One TXT File

author
Written By
Nick Rogers
Published On
December 3rd, 2026
Reading Time
9 Minutes Reading
Quick answer: To merge HTML files into text, number your pages, put them in one folder and run a script that removes the tags and writes a single TXT file. A Windows joiner can do the same through menus. Keep the original pages, since styling and pictures don’t survive.

Turning a stack of web pages into one TXT document is two jobs at once. Every page has to lose its tags, and the remaining words have to be stacked in the right order. Gluing the raw pages together won’t give you plain text, because all the code comes along. The script in this guide was run in Windows PowerShell 5.1 on four sample pages, including one without a title. It needs no Office suite. Steps for the Windows joiner come from product screenshots and haven’t been tried here. Below you’ll find what your merged file keeps, how to order the pages, the script and two other routes. If a separate TXT file for each source suits you better, see how to convert HTML to TXT.

What Stays When You Merge HTML Files Into Text

The table describes the output of the PowerShell script further down, so you know your limits before running it.

Page Part In merged.txt
File name and page title A header line above each page
Headings and paragraphs Kept as text on separate lines
Links starting with http Address added in round brackets
Pictures with alt text [Image: description]
Table cells Split by tabs
List items One per line without bullet marks
Menus in nav, scripts, styles and comments Removed
Text hidden by a style sheet Still there
Text that a script writes Missing

Number Your Pages 01, 02 and 10 First

The script sorts by file name, one character at a time. A page called 10.html would therefore land before 2.html. Add leading zeros, as in 01, 02 and 10. Your running order will then match the numbers. Also, copy the pages into a new folder like C:\HtmlToJoin so your originals aren’t touched.

Merge HTML Files Into Text With PowerShell 5.1

Open Windows PowerShell, paste the script and press Enter. Look for merged.txt in the same folder.

$folder = "C:\HtmlToJoin"
$all = foreach ($file in Get-ChildItem "$folder\*" -Include *.htm, *.html | Sort-Object Name) {
    $html = [System.IO.File]::ReadAllText($file.FullName)
    $title = [regex]::Match($html, '(?is)<title[^>]*>(.*?)</title>').Groups[1].Value.Trim()
    $text = $html -replace '(?is)<!--.*?-->|<(head|script|style|nav)\b.*?</\1>'
    $text = $text -replace '(?is)<img\s[^>]*?alt="([^"]+)"[^>]*>', '[Image: $1]'
    $text = $text -replace '(?is)<a\s[^>]*?href="(https?://[^"]+)"[^>]*>(.*?)</a>', '$2 ($1)'
    $text = $text -replace '(?i)<br\s*/?>|<(ul|ol)\b[^>]*>|</(p|div|h[1-6]|li|tr|pre|table)>', "`r`n"
    $text = $text -replace '(?i)</t[dh]>', "`t"
    $text = [System.Net.WebUtility]::HtmlDecode(($text -replace '<[^>]+>'))
    "===== $($file.Name): $([System.Net.WebUtility]::HtmlDecode($title)) ====="
    ($text -replace '(\r?\n[ \t]*){3,}', "`r`n`r`n").Trim()
    ""
}
[System.IO.File]::WriteAllLines("$folder\merged.txt", [string[]]$all)

A header like ===== 01.html: Page 01 title ===== shows you where each source starts. The script also turns codes like &amp; back into symbols. In the test, Hindi and accented words from UTF-8 pages came through intact.

Limitations: pages are read as UTF-8, one folder at a time. Pattern matching isn’t a full HTML reader, so unusual markup may slip through. An existing merged.txt is replaced.

Join 2 or 3 Pages by Hand in Notepad

With only a couple of pages, copying may be quicker than running anything.

  1. Open your first source in the browser, press Ctrl+A and then Ctrl+C.
  2. Paste it into an empty Notepad window.
  3. Type a divider line, then add the next one below it.
  4. Choose Save As with UTF-8 encoding and a .txt name.

Limitations: everything is manual work and it’s easy to skip a source. Link addresses won’t come with a plain paste into Notepad.

Merge HTML Files Into Text With a Windows Joiner

If scripts aren’t your thing, HTML input and TXT output are both on the menus of the 4n6 Document Joiner for Windows.

  1. Download the setup, install it and launch the app.

    Download Free Demo

  2. Click Open, move to HTML Files and add files or a folder.
    List of input types under Open with HTML Files outlined
  3. Review the loaded list and confirm that nothing is missing.
    Table of eight loaded web pages with size and date columns
  4. Under Export, select TXT.
    Export list showing ten formats with TXT outlined
  5. Use Browse on TXT Export Options to set the Location.
    Location box and Browse button outlined on the TXT settings
  6. Select Save and wait for the output.
    Save button outlined at the top of the TXT settings

Limitations: the product page puts the demo at 10 files per folder. Open the result and check the order, as the app wasn’t run for this guide.

Try a Small Numbered Folder First

Load a few sources in the demo and read the combined text from top to bottom.

Download Free Trial Select a Licence From $29

5 Checks on Your Merged TXT File

  • Count the headers or sections against your page total.
  • Scroll through and confirm the running order.
  • Search for < to catch any tag that stayed behind.
  • Read a few accented or non-English words.
  • Delete hidden or private text before you share your copy.

Working toward another output? You can merge HTML files to PDF or merge PDF files into a text file.

3 Merging Problems and Their Fixes

Pages Come Out in a Strange Order

Unpadded numbers are a common reason. Do this: rename your pages with leading zeros and run the script again. The same naming habit helps when you merge HTML files into DOC.

Accented Letters Turn Into a Black Diamond

An old page saved in a Windows code page may do this. In a test, café from that kind of page lost its last letter to a replacement mark. Do this: open that page in Notepad, save it again as UTF-8 and rerun. For other routes to text, see the guide on saving single pages as TXT.

The Same Footer Repeats After Every Page

Only the nav menu is stripped by default. Do this: change (head|script|style|nav) in the script to (head|script|style|nav|footer|aside). On a test page, that change removed both extra blocks. If you want the pages kept as web code, combine HTML files into one file.

Frequently Asked Questions

How do I merge HTML files into text?

Number the pages, place them in one folder and run the PowerShell script. The 4n6 Document Joiner handles the job through menus on Windows.

Do I need to convert each page to TXT first?

No. The script strips the tags and joins everything in a single pass.

Is Microsoft Word needed?

No. Windows PowerShell does the work, so you don’t need any Office program for it.

Can the merged file keep my pictures?

No. Plain text can’t hold images, although the script notes each description it finds.

Are link addresses kept?

Addresses beginning with http stay in brackets. Short relative links keep only their words.

Will the script change my HTML pages?

No. It reads them and writes a separate file named merged.txt.

Can I join Word documents into one text file too?

Yes. Our separate walkthrough covers joining Word documents as TXT.

Can I keep headings and colours after merging?

Not in a TXT file. Choose a document or web format if the look matters to you.

Which Joining Route Suits Your Folder?

Two or three pages: copy them into Notepad.

A longer folder and no Office: run the script on numbered copies.

Point-and-click work on Windows: test the joiner on a small set.

Google Preferred Source