Skip to content
FeaturesPricingBlogDownload

← All posts

Markdown to HTML: convert .md files into web pages

Convert Markdown to HTML with Pandoc or a small library, add a stylesheet, embed images in one file, and turn a folder of notes into linked pages.

A clean diagram card on a light background showing a Markdown file with headings and a table turning into an HTML page

To convert Markdown to HTML, run Pandoc with the standalone flag: pandoc notes.md -s -o notes.html writes a complete web page you can open in any browser. Leave out -s and you get an HTML fragment to paste into a template or a CMS. Add --css style.css to apply your own styles, or --embed-resources --standalone to pack images and styles into a single file you can email or archive.

Markdown was designed for this conversion. John Gruber's original description calls it "a text-to-HTML conversion tool for web writers," and every Markdown element has a direct HTML counterpart. The Pandoc details below are from the Pandoc manual (checked November 2026).

What does Markdown look like as HTML?

Each piece of Markdown syntax becomes one HTML element:

Markdown HTML
# Title <h1>Title</h1>
**bold** and *italic* <strong> and <em>
- item <ul><li>item</li></ul>
[text](https://example.com) <a href="https://example.com">text</a>
![Chart](chart.png) <img src="chart.png" alt="Chart">
A pipe table <table> with <thead> and <tbody>
A fenced code block with python <pre><code class="language-python">

A converter produces one of two things. A fragment is just these elements, ready to drop into an existing page. A standalone document wraps them in <html>, <head> and <body>, with a title and a character set, so the file works on its own.

How do you convert Markdown to HTML with Pandoc?

Install Pandoc from the installing page, or with brew install pandoc on a Mac, then run one of these in the folder that holds your file.

A fragment, printed to the terminal:

pandoc notes.md

A complete page with a title:

pandoc notes.md -s --metadata title="Project notes" -o notes.html

A page with a table of contents built from the headings:

pandoc notes.md -s --toc -o notes.html

If the file has no title, Pandoc warns that HTML requires one and uses the file name instead. Setting title in front matter at the top of the Markdown file works as well as the --metadata flag.

Pandoc reads its own Markdown dialect by default. If your notes are written for GitHub, add -f gfm so task lists, tables and autolinks are read the way GitHub reads them.

How do you style the HTML page?

Pandoc's default HTML template already includes a small stylesheet for readable margins and fonts. To use your own, write a CSS file and link it with --css:

body { max-width: 42rem; margin: 2rem auto; padding: 0 1rem; font: 17px/1.6 system-ui, sans-serif; }
pre { background: #f5f5f5; padding: 0.75rem; overflow-x: auto; }
table { border-collapse: collapse; }
th, td { border: 1px solid #ddd; padding: 0.3rem 0.6rem; }
pandoc notes.md -s --css style.css -o notes.html

--css adds a link to the stylesheet, so style.css has to travel with the HTML file. To make one self-contained file instead, add --embed-resources. Pandoc then writes the CSS and every local image into the HTML itself, which makes the file larger but impossible to break by moving it:

pandoc notes.md -s --css style.css --embed-resources -o notes.html

--embed-resources replaced the older --self-contained flag in Pandoc 2.19.

Can you convert Markdown to HTML without Pandoc?

Yes. Most programming languages have a Markdown library with a command line, and each produces a fragment:

Tool Command Note
Python-Markdown python -m markdown -x tables notes.md > notes.html Tables need the tables extension
marked (Node.js) npx marked -i notes.md -o notes.html Follows GitHub Flavored Markdown by default
GitHub Commit the .md file and view it in the repository Renders on the site; no HTML file to download

These libraries are what static site generators and documentation tools use underneath. If you want a whole website rather than a few pages, a generator saves you from writing the page template yourself.

Is raw HTML inside Markdown kept?

It depends on the converter. Pandoc passes raw HTML through to the output, so a <details> block or an <sup> tag in your note appears in the page as written. Many website and chat renderers remove raw HTML, or only allow a short list of tags, to keep pages safe from injected scripts. If your notes rely on inline HTML, check the output of the exact tool you publish with. The HTML in Markdown page lists which tags commonly survive.

How do you convert a folder of notes into linked pages?

Convert each file in a loop, and rewrite links between notes so other.md becomes other.html. Pandoc doesn't change link targets on its own, but a four-line Lua filter does. Save this as md-links.lua:

function Link(el)
  el.target = el.target:gsub("%.md$", ".html"):gsub("%.md#", ".html#")
  return el
end

Then convert every note in the folder:

for f in *.md; do
  pandoc "$f" -s --lua-filter=md-links.lua --metadata pagetitle="${f%.md}" -o "${f%.md}.html"
done

pagetitle sets the browser tab title without adding a visible heading, which suits notes that already start with #. Images linked with relative paths keep working as long as the image folder sits next to the HTML files.

What should you check in the HTML?

Open the result in a browser and look at the elements that differ most between converters:

  • Line breaks. In standard Markdown a single line break inside a paragraph is ignored. If your notes rely on one line per thought, add two spaces or a backslash at the end of the line, or use a converter option for hard breaks.
  • Code blocks. Confirm the language class is present, as described in Markdown code blocks, and that long lines scroll instead of overflowing.
  • Tables. Without CSS, tables have no borders. Add the table rules above.
  • Images. Relative paths resolve from the HTML file's location, not from where the Markdown file was.
  • Diagrams. A mermaid code block becomes a plain code block unless the page loads a diagram script.

Common questions

Does Pandoc highlight code in the HTML?

Yes. In standalone HTML, Pandoc colors fenced code blocks that name a language, using its own built-in highlighter and a small inline stylesheet, so no script is needed in the page. Blocks without a language name are left plain.

How do you show math in the HTML?

Add --mathjax to the Pandoc command. The page then loads MathJax and renders the LaTeX between dollar signs. Without a math option, Pandoc writes equations as plain text with Unicode symbols where it can.

Can you convert the HTML back to Markdown?

Yes, with Pandoc or a library such as Turndown, though anything you added only in HTML, such as classes and styles, is lost on the way back. HTML to Markdown covers the steps and the cleanup.

Markdown to HTML in Noteline

Noteline, which we make, saves the open note as a web page from File > Save As > HTML (.html) in the desktop app. The file is a standalone page with the note's title in the <title> tag, GFM tables, code blocks carrying their language class, and single line breaks kept as <br>, matching what you see in the editor. It has no stylesheet, raw HTML in the note is left out, images stay linked by relative path rather than embedded, and Mermaid diagrams remain code blocks. When you need styling, a table of contents or embedded images, run Pandoc on the same .md file with the commands above.

Start with one note. Keep the file.

Open a folder and write. Every note is a plain .md file, with no account to create.

Try desktop free for 14 days ↓Free on iPhone, iPad and Android →

Desktop: 14-day trial, then $9.99 once. Mobile apps: free. No account.

Keep reading

  • HTML in Markdown
  • Markdown code blocks
  • Markdown front matter
  • How to keep AI meeting notes as Markdown files you own
  • AI memory files: what your assistant should remember, kept in Markdown
  • An AI research workflow in Markdown: sources, summaries and claims

A Markdown note editor with everything you need

We’re listening

Tell us what you need or what gets in your way. If something isn’t working, write to us any time.

contact@noteline.io→

Product

  • Download
  • Pricing
  • Features
  • Changelog

Learn

  • Markdown syntax
  • Use cases
  • Blog

Compare

  • vs Obsidian
  • vs Notion

Support

  • Help
  • Support
  • Privacy
  • Terms

© 2026 Notelinecontact@noteline.io