Merge Markdown Files into One

Drop in your .md files, put them in order, and download a single Markdown document. Remove front matter, match heading levels and add a table of contents if you need them. Runs in your browser; nothing is uploaded.

Files (3)

These are example files. Add or drop your own and they replace them.

  1. 1

    01-introduction.md

    35 words · starts at H1

  2. 2

    02-install.md

    23 words · starts at H1

  3. 3

    10-faq.md

    31 words · starts at H1

3 files · 89 words · 7 headings

Rendering…

Merge options
Between files

What merging does to your files

Plain concatenation (cat *.md) leaves problems behind: files come out in the wrong order, every file's YAML front matter lands in the middle of the document, and a chapter that starts with ## sits under one that starts with #. This tool handles those cases before joining the files.

  • Order: each batch of files you add is sorted by name in natural order, so 2 comes before 10. Drag, use the arrows, or press Sort by name at any time.
  • Front matter: the --- (YAML) or +++ (TOML) block at the top of each file is removed. Choose Keep the first file's to put that one block back at the very top.
  • Headings: Match levels shifts each file so its highest heading becomes H1 (or H2 under an added file title). Setext headings (underlined with === or ---) are rewritten as # headings when they move.
  • Table of contents: built from the merged headings, with anchors that follow GitHub's rules, so the links work when the file is viewed on GitHub.

How to use Merge Markdown

  1. Click Add files or drop your .md files onto the tool. The example files are replaced by yours.
  2. Put the files in order: drag the handle, use the arrows, or press Sort by name.
  3. Pick a separator and, if you need them, front matter, heading and table of contents options.
  4. Check the preview, then Copy or Download .md.

Why use tinyMD for Merge Markdown

  • Add many .md files at once (picker or drag and drop), or paste text as a file
  • Reorder by dragging, with the arrow keys, or with the up and down buttons; sort by name in natural order (chapter-2 before chapter-10)
  • Separate files with a blank line, a horizontal rule (---) or a page break (<!-- pagebreak -->)
  • Remove YAML front matter from every file, or keep the first file's block at the top
  • Match heading levels across files, or demote every heading one level; headings inside code blocks are left alone
  • Optional title above each file (front matter title or file name) and a table of contents with GitHub-style links
  • Live rendered preview and Markdown source, then copy or download one .md file
  • Runs in your browser: the files are never uploaded

Frequently asked questions

How do I merge multiple Markdown files into one?

Add or drop all the .md files onto this page, put them in order, and click Download .md. The merged file is built in your browser as you change the order or options, so the preview always shows what you will download.

What order are the files merged in?

The order of the list. Files you add together are sorted by name in natural order (chapter-2.md before chapter-10.md) and added to the end. You can drag a file, use its up and down arrows, focus its handle and press the arrow keys, or click Sort by name.

What happens to YAML front matter?

By default it is removed from every file, because a second front matter block in the middle of a document shows up as a horizontal rule followed by stray text. Choose Keep the first file's to put the first file's block back at the very top. The front matter title can also be used as a heading above each file.

My files use different heading levels. Can it fix that?

Yes. Headings: Match levels across files shifts each file so its highest heading becomes H1, or H2 when you add a title above each file; the other headings move with it. Demote all one level pushes every heading down by one. Lines starting with # inside code blocks are not touched.

Can I add a page break between files?

Choose Page break and <!-- pagebreak --> is placed between files. tinyMD's Markdown to PDF tool starts a new page there. Other converters may ignore it; in that case use a horizontal rule instead.

Does the table of contents link to the headings?

Yes. Links use GitHub-style anchors (lowercase, spaces turned into hyphens, punctuation removed, repeated headings numbered), so they work on GitHub and in other tools that follow the same rules. Choose how deep it goes, from H1 only to H1–H4.

Are my files uploaded?

No. The files are read and merged by JavaScript in your browser tab; nothing is sent to a server.

Can I merge text that isn't saved as a file?

Yes. Click Paste, give it a name, paste the Markdown and click Add to list. It is merged like any other file.