How to Convert Markdown to HTML
You paste Markdown into a converter, copy the HTML out, drop it into your page — and it is subtly wrong. Your carefully separated lines have run together into one paragraph. Your footnote turned into a broken link. Your front matter is now a heading.
None of that is a bug. Markdown to HTML conversion follows rules that are stricter than most people expect, and the two or three that trip everyone up are easy to fix once you know them. This guide walks the whole process: how to convert Markdown to HTML in a few seconds with FileNaut’s Markdown to HTML converter, what the output actually contains, and the seven behaviours that surprise people — every one of them tested against the exact converter this page links to, not assumed.
How to Convert Markdown to HTML
The whole job takes about ten seconds and happens entirely in your browser — nothing is uploaded to a server.
- Open the Markdown to HTML converter. It loads with a sample document already in place so you can see the shape of the output immediately.
- Add your Markdown. Either paste it into the left-hand pane, or click Upload .md to load a
.mdor.txtfile straight off your disk. - Read the HTML on the right. It regenerates on every keystroke, so you can fix a line and see the corrected HTML instantly.
- Take the output. The copy button puts the HTML on your clipboard; the download button saves it as
document.html.
If you would rather see the rendered result than the HTML source, the Markdown Viewer shows the formatted page, and the Markdown Editor gives you source and preview side by side while you write.
Why Your Line Breaks Disappeared
This is the single most common complaint about Markdown to HTML conversion, and it is worth understanding rather than working around.
In Markdown, a single newline is not a line break. It is whitespace. Two lines typed one under the other are treated as one continuous paragraph, exactly as HTML itself treats them. So this input:
Line one
Line two
produces a single paragraph containing both lines — no <br> anywhere. That is correct Markdown behaviour, not a fault in the converter.
There are four ways to get the break you wanted. All four were run through the converter to confirm what they output:
| What you type | What you get | Use it when |
|---|---|---|
| Two spaces at the end of the line | <br> inside one paragraph | Addresses, poetry, anything where the lines belong together |
| A backslash at the end of the line | <br> inside one paragraph | Same as above, but visible in your source so nobody deletes it by accident |
| A blank line between them | Two separate <p> elements | Genuinely separate paragraphs — this is what you want most of the time |
A literal <br> tag | The tag, passed through untouched | Last resort — it works, but it stops the file being portable Markdown |
The trailing-spaces trick is the traditional answer, but invisible syntax is fragile — editors that trim trailing whitespace on save will silently delete it. The backslash does the same job and survives.
The Output Is a Fragment, Not a Web Page
Worth knowing before you double-click the downloaded file and wonder why it looks unstyled. Markdown to HTML converters output an HTML fragment: the headings, paragraphs and lists, and nothing else. A document like this:
# Café
Hello **world**.
converts to exactly two lines of HTML — an <h1> and a <p>. There is no <!DOCTYPE>, no <html>, no <head>, no <meta charset> and no stylesheet.
That is the right default. If you are pasting into a CMS, a template, an email builder or a React component, a fragment is exactly what you need — a full document would break the page you are pasting into.
But if you want a file you can open in a browser on its own, wrap it. Paste the converted HTML where the comment sits:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My Document</title>
</head>
<body>
<!-- paste the converted HTML here -->
</body>
</html>
The <meta charset="utf-8"> line matters more than it looks. Accented characters, curly quotes, em dashes and non-Latin scripts all survive conversion intact, but a browser opening a local HTML file with no declared character set can guess the wrong encoding and turn Café into mojibake. One line prevents it.
If you want a finished, styled page rather than a wrapper you maintain by hand, the HTML File Generator builds the whole document for you, and Markdown to PDF or Markdown to Word skip HTML altogether.
Seven Conversions That Do Not Do What You Expect
Each of these was run through the converter and the output inspected. They are the difference between HTML that works first time and an afternoon of debugging.
| Markdown | What actually happens | Fix |
|---|---|---|
Front matter (--- block at the top) | Not stripped. The dashes become a horizontal rule and your title: line becomes a heading. | Delete the front matter before converting |
Footnotes ([^1]) | Not supported. The marker is mangled into a link pointing at the footnote label. | Write footnotes as ordinary links, or use a converter with a footnote plugin |
| Headings | Get no id attribute, so anchor links and tables of contents will not jump anywhere. | Add id attributes after conversion, or let your CMS generate them |
| Link URLs containing spaces | Do not become links at all — the whole thing stays as literal text. | Wrap the URL in angle brackets, or replace each space with %20 |
| Fenced code with a language | Becomes <pre><code class="language-js"> — the class is there but no colours are. | Add a highlighter such as Prism or highlight.js on the page |
Straight quotes, --, ... | Stay exactly as typed. No smart-quote or em-dash substitution happens. | Type the real characters if you want them |
| Underscores inside words | Safe. snake_case_name survives without turning into italics. | Nothing — this one works the way you hoped |
Two more worth having in your head. Ampersands are escaped correctly and existing entities are not double-escaped, so AT&T and & both come out right. And ordered lists remember where you started them: begin at 5 and you get <ol start="5">.
Tables, Task Lists and the Rest of GitHub Flavored Markdown
The converter runs GitHub Flavored Markdown, so the extensions most people actually use are all supported.
Tables convert cleanly, including alignment. A colon on the right of the dashes produces align="right" on every cell in that column; a colon on both sides centres it. The leading and trailing pipes are optional — a table written without them converts identically. And a pipe inside a cell works if you escape it with a backslash, which is the one piece of table syntax nobody remembers. If you would rather not write the pipes at all, the Markdown Table Generator builds the syntax from a grid.
Task lists become real checkbox inputs, rendered checked and disabled. Strikethrough works, and bare URLs autolink without needing angle brackets.
Nested lists indent with either two or four spaces — both produce properly nested markup, so whichever habit you have is fine. Blockquotes nest as deep as you take them, and a tab-indented line becomes a code block just as a four-space indent does.
For a full syntax reference while you write, keep the Markdown Cheatsheet open.
Raw HTML Passes Straight Through — Including Scripts
Markdown was designed to allow inline HTML, and the converter honours that. Any HTML you put in your Markdown appears in the output untouched. That is genuinely useful: it is how you add a <video>, an iframe, or a <div> with a class Markdown has no syntax for.
It also means the conversion does no sanitising whatsoever. A <script> tag in the input is a <script> tag in the output. An onclick attribute survives intact.
For your own documents this is a feature and you can stop reading here. It matters in exactly one situation: if you are converting Markdown that someone else wrote — comments, user profiles, submitted content — and publishing the result on a page. That is a cross-site scripting hole. Run the HTML through a sanitiser such as DOMPurify before it reaches the page, and never trust converter output that started as user input.
Converting from the Command Line or in Code
If you are converting one file, the browser tool is faster than installing anything. For a hundred files, or as a build step, use a script.
Pandoc is the most capable option and the one to reach for when you need a complete styled document rather than a fragment:
pandoc input.md -f markdown -t html -s -o output.html
The -s flag is what makes it standalone — it writes the doctype, head and charset for you. Drop -s and you get the same fragment the browser tool gives you.
Node, with no install, using the same library the browser tool uses:
npx marked -i input.md -o output.html
Python, if that is already in your stack:
pip install markdown
python -m markdown input.md > output.html
One caution: these three do not agree on the edge cases. Python’s markdown package does not enable tables unless you ask for the extension, and Pandoc supports footnotes where the browser tool does not. If output has to match across tools, pick one and convert everything with it.
Tips for Cleaner Output
- Convert a small sample first. Paste one representative section, check the HTML, then run the whole document. Catching a front-matter or footnote problem on ten lines is faster than finding it in a thousand.
- Strip front matter before you paste. It is the most common cause of a stray horizontal rule at the top of an otherwise perfect page.
- Use blank lines liberally. Most spacing problems in converted HTML are a missing blank line between a paragraph and the list or table that follows it.
- Minify before shipping. Converted HTML carries a newline after nearly every tag. Run it through the HTML Minifier to strip that out for production.
- Going the other way? If you have HTML or a PDF and need Markdown, PDF to Markdown handles the reverse trip.
Frequently Asked Questions
How do I convert a Markdown file to HTML? ▼
Why are my line breaks missing after converting Markdown to HTML? ▼
<br>. To create separate paragraphs, put a blank line between them.Does the converted HTML include a full page with head and body tags? ▼
<meta charset="utf-8">.Is the Markdown to HTML converter free, and does it upload my files? ▼
Do Markdown tables convert to HTML tables? ▼
<table> markup, and column alignment is preserved — a colon on the right of the dashes adds align="right" to that column. Leading and trailing pipes are optional. To include a literal pipe inside a cell, escape it with a backslash.Why did my front matter turn into a heading? ▼
--- is read as a horizontal rule and the lines beneath it as a heading. Delete the front matter block before converting, or use a static site generator that strips it as part of its build.Are footnotes supported? ▼
[^1] is not part of core GitHub Flavored Markdown, and the marker gets turned into a link pointing at the footnote label rather than a proper footnote. If you need footnotes, convert with Pandoc, which supports them, or rewrite them as ordinary links.Will my code blocks be syntax highlighted? ▼
<pre><code class="language-js"> — the language is recorded as a class, but colours come from a highlighting library. Add Prism or highlight.js to the page you paste into and it will pick up those classes automatically.Is it safe to publish HTML converted from Markdown other people wrote? ▼
<script> tags and event attributes such as onclick. For your own documents that is harmless and useful. For user-submitted content it is a cross-site scripting risk — run the output through a sanitiser like DOMPurify before rendering it.What is the difference between Markdown to HTML and a Markdown preview? ▼
Ready to try it?
Use the tool right now — free, no signup, no upload.