Merge HTML Files Online

Combine multiple HTML files into one free in your browser. Reorder pages, preserve CSS, preview the merged document, and download a clean HTML file without uploading your code.

How to Merge HTML Files Into One

1

Add your files

Drop two or more .html or .htm files or browse. Up to 20 MB each.

2

Choose settings

Set the file order, pick a merge mode, and choose how to handle CSS and scripts.

3

Download

Preview the merged page, then copy it or download one HTML file.

A More Capable HTML Combiner

Three merge modes

Build a smart HTML5 document, combine body content only, or concatenate the original source.

CSS and script controls

Preserve styles, optionally keep JavaScript, and remove duplicate resource references.

Sandboxed preview

Review the combined document before downloading it, without running source scripts in the preview.

Browser-local processing

Your HTML file contents are read and merged locally during normal tool use instead of being uploaded for conversion.

HTML Merger Questions

HTML File Merger Guide

How to Combine Multiple HTML Files Into One

An HTML merger takes the useful content from two or more HTML documents and creates one downloadable file. Add your files, arrange them in the order they should appear, select a merge mode, and choose Merge HTML Files. Use the preview to inspect the result before you download the final .html document.

Smart document, body-only, or raw HTML merge

Smart document mode is the best default for combining complete pages. It creates one doctype, head, and body, then collects the body content from every source file. It can preserve inline styles and stylesheet links, remove repeated resource references, and optionally keep scripts. Body-only mode excludes source CSS and JavaScript. Raw concatenation simply joins the original source documents in order and is useful when another parser will process the result later.

What happens to CSS, JavaScript, images, and links?

CSS rules keep their source order, so later rules can override earlier rules through the normal cascade. JavaScript is optional because scripts from separate pages can share global variables or register the same event twice. Relative image, stylesheet, script, and link paths remain relative; review them when files came from different folders. The tool warns about common conflicts, but it cannot infer the intended folder structure of a website.

HTML combiner use cases

  • Join header, content, and footer fragments into one HTML page.
  • Combine documentation chapters into one offline document.
  • Merge exported reports before archiving, sharing, or printing.
  • Assemble email template sections for final testing.
  • Join scraped HTML fragments for a single downstream parser.

HTML merging is different from linking pages

Merging creates one physical HTML file. Linking keeps separate pages and connects them with anchors such as <a href="page.html">. Use merging when you need one portable document or a single processing input. Keep pages separate when they need independent URLs, navigation, metadata, or loading behavior.

Check the merged file before publishing

Preview the output, inspect duplicate IDs, test interactive behavior, and confirm that relative assets still resolve. For deeper inspection, open the downloaded file in a code editor and validate its structure. You can also browse the site's HTML format resources for related tools and guides.

HTML Merger Settings Reference

SettingDefaultWhat it does
Merge modeSmart documentSmart document builds one HTML5 page with a single head and body. Body content only does the same without any source CSS or JavaScript. Raw concatenation joins the complete source files unchanged.
Preserve CSSOnCopies every <style> block and stylesheet <link> into the merged head. Each copied <style> block starts with a comment naming its source file.
Preserve JavaScriptOffKeeps scripts and places them at the end of the merged body, after all file content.
Remove duplicate resourcesOnKeeps a stylesheet with the same href, an identical <style> block, or a script with the same src or code only once.
Source commentsOnAdds a comment such as <!-- Source 2: content.html --> before each file's content.
Wrap file sectionsOffWraps each file's body in <section data-merged-source="file.html">, so you can style or select one file's content.
Compact outputOffRemoves trailing spaces and repeated blank lines from the result.

Preserve CSS, Preserve JavaScript and Remove duplicate resources apply to Smart document mode only. Wrap file sections is not offered in Raw concatenation, because that mode never changes the source markup.

What the Merged HTML File Looks Like

This is the result of merging the tool's three sample files, header.html, content.html and footer.html, with the default Smart document settings.

HTMLmerged.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="generator" content="Merge JSON Files HTML Merger">
  <title>Acme Studio</title>
  <style>
    /* header.html */
    body { margin: 0; font-family: system-ui, sans-serif; color: #292524; }
    header { padding: 32px; background: #1c1917; color: white; }
  </style>
  <style>
    /* content.html */
    main { max-width: 720px; margin: 0 auto; padding: 48px 24px; }
  </style>
  <style>
    /* footer.html */
    footer { padding: 24px; background: #f5f5f4; text-align: center; }
  </style>
</head>
<body>
  <!-- Source 1: header.html -->
  <header><h1>Acme Studio</h1></header>

  <!-- Source 2: content.html -->
  <main>
    <h2>One complete HTML page</h2>
    <p>This content came from a separate file.</p>
  </main>

  <!-- Source 3: footer.html -->
  <footer>Built from three HTML files.</footer>
</body>
</html>
  • One head for the whole page. The title, the lang attribute and meta tags come from the first file only, so put the page you want to lead with at the top of the list.
  • Styles stay in source order. When two files style the same element, the rule from the later file wins, exactly as it would in one stylesheet.
  • Body content is copied as written. IDs, classes and relative links are not rewritten, so two pages that both use id="main" will still share it after merging.

Merging Other Document Formats

If your pages started life as Markdown, combine the source files with the Markdown Merger, which keeps headings and front matter, and convert once at the end. For Word reports and handouts, Merge Word Files joins .docx documents while keeping their formatting, images and page layout. Pages saved from a browser as a single .mhtml file can be turned into a PDF with the MHTML to PDF converter. Exported HTML that is too large to open comfortably in an editor can be searched in the Large Text File Viewer before you merge it, and EPUB books, whose chapters are XHTML files, can be edited in place with EPUB Find and Replace or combined into one book with the EPUB Merger. To go the other way and break one long HTML document into separate pages, use the HTML Splitter.