Affiliate
Never lose a file again. Back up everything you make here with pCloud, free to startSecure Swiss cloud storage for your files, on every deviceStart free with pCloud and upgrade only if you need more spaceOne click from download to safe backup. Try pCloud free

HTML Splitter

Split an HTML file into multiple pages by heading, CSS selector, marker or equal parts, directly in your browser.

Split HTML Files Into Multiple Files

Split by structure

Cut at headings, at any CSS selector or at your own comment markers, or into equal parts that never break an element.

Pages that still look right

Every part keeps the original head, styles and wrapper elements, with optional Previous, Contents and Next links.

Links that still work

In-document #anchor links are pointed at the part that holds the target, and every file is re-parsed before you download it.

How to Split an HTML File

Your original file is not changed; the parts are new files.

1

Add your HTML file

Choose or drop one .html, .htm or .xhtml file up to 50 MB, paste HTML, or try the sample file.

2

Choose how to split

Pick a heading level, a CSS selector, a comment marker or a number of equal parts. Part counts update live.

3

Set the output

Keep the head and CSS, add navigation links, rewrite anchors and set the file name pattern.

4

Preview and download

Check each part in a sandboxed preview, then download single files or everything as a ZIP.

Split Modes and Settings Explained

By heading
Starts a new part at every H1, H2 or H3. The default is the highest level that appears at least twice, which is usually the chapter level.
By CSS selector
Starts a new part before each element that matches, for example section, article, .chapter, div.page or hr. Invalid selectors are reported straight away.
By split marker
Splits at an HTML comment such as <!-- split --> that you placed in the source. The marker is removed from the output.
Equal parts
Divides the document into 2 to 100 parts of similar text length, breaking only between block elements.
Merge intro into part 1
Content before the first split point, such as a title and a summary, joins part 1 instead of becoming a separate introduction file.
Keep <head> in every part
Each part is a complete HTML document with the original styles and meta tags and a title of the form Original title – Part heading. Turn it off to get body-only fragments.
Navigation links
Adds Previous, Contents and Next links at the top and bottom of every part and writes an index.html table of contents.
Rewrite #anchor links
Points in-document links at the part file that now contains the target id, so a table of contents keeps working.
Keep <script> elements
Off by default. When on, scripts from the original head and body are copied into the parts.
File name pattern
Builds names from {n} (the zero-padded part number), {slug} (the part heading) and {name} (the original file name). The default is {name}-{n}-{slug}.html.

Want the opposite? The HTML Merger combines several HTML files into one page, and works well for rejoining parts you split here.

Are My HTML Files Uploaded?

No. Your browser reads the file, parses it with its own HTML parser and builds every part and the ZIP locally. There is no upload, no account, and nothing is stored after you close the page.

Will CSS and Links Still Work After Splitting?

Yes, when the parts stay together in one folder. Each part keeps the original <style> blocks, stylesheet links and wrapper elements, and #anchor links are rewritten to the right part. Relative image and CSS paths are copied as written.

Frequently Asked Questions

Complete HTML Splitter Guide

How to Split an HTML File Into Multiple Pages

An HTML splitter takes one long HTML document and turns it into several smaller ones. That sounds simple, but HTML is a tree of nested elements, not a list of lines. If you cut a file at line 5,000 the way you would split a log file, you almost always end up in the middle of a <div>, a table or a paragraph, and both halves are broken. A proper split happens between elements, keeps the document structure around each piece, and gives every part what it needs to display correctly on its own.

Why split HTML at all?

  • Long documents. Manuals, specifications, policy handbooks and reports often arrive as one huge page. Separate pages are easier to read, link to and update.
  • Exported Word and Google Docs HTML. "Save as web page" and "Download as HTML" produce a single file for the entire document, with every heading in one place. Splitting by heading turns it into one page per chapter.
  • Ebook chapters. EPUB books store each chapter as a separate XHTML file. Splitting a book-length HTML file by H1 or H2 gives you chapter files ready for an EPUB editor. If you already have EPUBs, the EPUB Merger combines books and EPUB Find and Replace fixes text across all chapters.
  • Faster pages. A 10 MB page with hundreds of images is slow on phones. Ten 1 MB pages load quickly and only fetch the images each reader actually sees.
  • CMS imports. WordPress, Ghost, Confluence and most documentation platforms import one page per file. Splitting first saves you from copying and pasting each section by hand.

How headings structure a document

HTML has six heading levels, <h1> to <h6>, described in the MDN guide to heading elements. A well-written document uses them like an outline. The title is usually the only H1, chapters are H2 and sections within a chapter are H3. The WHATWG HTML Living Standard defines how these elements and the sectioning elements (<section>, <article>) fit together.

That is why splitting by heading works so well: each heading marks the start of a unit a reader would treat as a page. The tool counts the H1, H2 and H3 elements when you load a file and picks the highest level that appears at least twice. A document with one H1 title and eight H2 chapters is split into chapters, not into a single page. Exported documents do not always follow the rules, though. Some use bold paragraphs instead of headings, or skip from H1 to H4. If the counts look wrong, check the source or try another mode.

Choosing a split mode

  • By heading is the right choice for most documents, especially Word and Google Docs exports. Use H2 for chapters and H3 if each chapter is still too long.
  • By CSS selector suits HTML that is already divided into containers, such as section, article, div.page or .chapter. A selector of hr splits at every horizontal rule, which many older pages use as a section break.
  • By split marker gives you full control. Add <!-- split --> to the source wherever you want a break. Comments are invisible in browsers, so the marker does no harm if it stays in the original.
  • Equal parts is for documents without useful structure, such as a long log or a scraped transcript, when you only need smaller files. Parts are balanced by visible text, not bytes, so a part with a large inline image may be bigger on disk.

What happens to CSS, scripts and links

CSS. With Keep <head> on, every part gets a copy of the original head: inline <style> blocks, stylesheet <link> elements, the viewport tag and other meta tags. The output is always UTF-8, so the charset is set to UTF-8 even if the source used windows-1252 or UTF-16. The tool also recreates the wrapper elements around each part. If your chapters sit inside <main class="content">, every part has that same wrapper, so a rule like .content p still applies.

Scripts. Scripts are left out by default. A script written for the full page often looks for elements that are now in another file, and copying it into twenty parts makes it run twenty times. If your pages depend on JavaScript, turn the option on and test the parts in a browser.

Links. A table of contents that links to #installation breaks once the Installation section moves to another file. The tool records which part contains every id and rewrites those links to guide-03-installation.html#installation. Relative links to images, stylesheets and other pages are copied exactly as written, so keep the parts in the same folder as the original assets.

Splitting HTML by hand or on the command line

For a small file you can split HTML manually. Open it in a code editor, copy the head, and paste it with each section into a new file. That works for three sections, but not for forty, and fixing anchor links by hand is slow. A good editor helps; see our guides to the best HTML editors for Linux and the best HTML editors for Android.

Older command-line tools such as Splity, htmlsplit and htsplit split HTML at markers or headings, but they are Perl scripts from the early 2000s that need a Perl install and expect tidy, predictable markup. Writing your own script in Python with BeautifulSoup or lxml is the most flexible route: parse the file, find the headings, and move siblings into new documents. It also means handling nested wrappers, copying the head, fixing anchors and naming files yourself. Library splitters built for AI pipelines, such as LangChain's header splitter, return text chunks for embeddings rather than HTML pages you can publish.

This tool does that work in the browser. It uses the browser's own HTML parser, so messy real-world markup is read the same way a browser displays it. It shows how many parts each mode would create before you commit, and re-parses every output file to check that no text was lost.

Publishing the split pages

Download everything as a ZIP and extract it into the folder that holds the original file, so relative images and stylesheets resolve. If navigation is on, index.html is the entry point and every part links back to it. Choose a file name pattern before you split, because renaming files later breaks the rewritten links. The default {name}-{n}-{slug}.html keeps parts in reading order in any file browser and gives search engines a readable URL. For a website, also give each part a unique meta description after splitting, since every part starts with a copy of the original one. To undo a split, add the parts in order to the HTML Merger.

Troubleshooting

  • "No headings were found." The document may use styled paragraphs instead of real headings. This is common in Word exports. Try a CSS selector such as p.Heading1, or add split markers.
  • Only one part is created. The chosen level occurs once, usually because H1 is the document title. Pick H2, or a different mode.
  • Images are missing in the preview. The preview cannot load relative paths. They work once the parts are saved next to the original image folder. Images embedded as data URIs always show.
  • The text count warning appears. The tool compares the visible text of all parts with the original. A difference above 1% usually comes from invalid markup that the parser repaired differently in a fragment. Open the file in the W3C Nu HTML Checker and fix the reported errors, then split again.
  • The file is too large to open in an editor. Inspect it first in the Large Text File Viewer, which searches multi-gigabyte files without loading them whole.

Splitting other formats

The same idea, split by structure rather than by line, applies to other formats. The XML File Splitter divides XML by element, the JSON File Splitter splits large JSON arrays, and the TXT File Splitter handles plain text by lines or size. If your source starts life as Markdown, it is often easier to keep chapters as separate files and combine them with the Markdown Merger when you need one document. For more HTML tools, see the HTML format page.

More HTML and file splitting tools

Rejoin pages, split other formats, or browse every HTML tool.