Markdown to HTML Converter, Sanitized & Safe avatar

Markdown to HTML Converter, Sanitized & Safe

Pricing

from $0.70 / 1,000 documents converted

Go to Apify Store
Markdown to HTML Converter, Sanitized & Safe

Markdown to HTML Converter, Sanitized & Safe

Converts Markdown to clean, sanitized HTML: texts, file URLs or Apify dataset columns. GFM tables, task lists, footnotes, code blocks, heading ids, optional table of contents, safe links. Failed documents are free; empty input runs a free demo.

Pricing

from $0.70 / 1,000 documents converted

Rating

0.0

(0)

Developer

Actor Factory

Actor Factory

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

6 days ago

Last modified

Features

Limited permissions

Share

Convert Markdown into clean, safe HTML, one row per document (source, html, title, headings, wordCount, tocHtml, error). Give it Markdown texts, links to .md files or a column of an Apify dataset. Tables, code blocks, task lists and footnotes become HTML; headings get ids; a table of contents is one switch away; scripts and unsafe links are removed. No browser, no LLM, no API key.

Try it free: leave the input empty and press Start. The demo converts two sample documents and is not charged (rows carry _demo: true). The second sample contains a <script> tag and a javascript: link, so you can see what the sanitizer does.

Who this is for

  • You write in Markdown and publish somewhere that wants HTML: blog posts, help-center articles, release notes, a CMS or a newsletter tool with an HTML box. Convert a whole folder's worth of files in one run instead of pasting them one by one.
  • You have Markdown from a model or from users: AI answers, comments, support replies, form input. Turning that into HTML and putting it on a page is only safe if the HTML is cleaned first. The sanitizer is on by default.
  • You build pages or documents from a dataset: another Actor produced a markdown column and you need html next to it, with a title and a table of contents for each row.

What you get

sourcetitlehtml (shortened)wordCount
sample-release-notes.mdRelease notes<h1 id="release-notes">Release notes</h1> ... <table> ...37
sample-untrusted-input.mdUntrusted input<p>This text came from a form ...</p> (no script, no handler)27
https://example.com/missing.md0 (error http_404)
  • GitHub-style Markdown: tables with alignment, strikethrough, task lists (- [x]), footnotes ([^1]), fenced code blocks with the language kept as class="language-python"
  • Heading ids: every heading gets an id made from its text (getting-started; Japanese headings keep their characters; repeated headings get -1, -2)
  • Table of contents: a nested list with working links in tocHtml, up to the depth you choose, and optionally also placed at the top of html
  • Sanitizing (on by default): only a safe list of tags, attributes and link types is kept. <script>, <style>, <iframe>, forms, on... handlers, javascript: and data: links are removed
  • Links: optional target="_blank" for external links, and rel="noopener noreferrer" (on by default)
  • Row fields: title is the first heading, headings lists level, text and id of every heading, wordCount counts words (characters for Japanese, Chinese and Korean text)
  • Three inputs, mixable in one run: Markdown texts, file URLs, datasets

Price

$1.00 per 1,000 documents ($0.001 per converted document). 1,000 documents cost $1.00, 5,000 cost $5.00. On the Apify Free plan, the $5 of monthly platform credit covers about 5,000 documents. Only successful conversions are charged. Failed documents (404, timeout, too large, missing field), empty documents and the demo are free. Set a maximum cost per run to cap spend: when it is reached the run stops cleanly and does not write the rest. The status message and the STATS record (stoppedAtChargeLimit: true) say so. If the maximum is lower than the price of one document, the run fails at the start and nothing is converted or charged.

Input

{
"markdownTexts": ["# Hello\n\nThis is **Markdown**."],
"fileUrls": ["https://example.com/docs/intro.md"],
"datasetIds": ["WkzbQMuFYuamGv3YF"],
"markdownField": "markdown",
"toc": true,
"tocDepth": 3,
"sanitize": true,
"linkTargetBlank": true
}
FieldDefaultMeaning
markdownTextsMarkdown documents, one string each
fileUrlsPublic links to .md or plain-text files
datasetIdsDatasets whose items hold Markdown (a Console dataset URL works too)
markdownFieldmarkdownField holding the Markdown in a dataset item (a.b for nested)
gfmonTables, strikethrough, task lists, footnotes
toc / tocDepth / prependTocoff / 3 / offTable of contents, its deepest level, and whether to also put it at the top of the HTML
headingIdsonIds on headings (always on with toc)
sanitizeonRemove everything unsafe
allowRawHtmlonKeep HTML tags written inside the Markdown (safe ones, when sanitizing)
linkTargetBlankoffNew tab for external links
addNoopeneronrel="noopener noreferrer"
lineBreaksoffA single line break becomes <br>

Leave texts, file URLs and datasets all empty for the free demo.

Output

One dataset row per document:

{
"source": "text#0",
"html": "<h1 id=\"hello\">Hello</h1>\n<p>This is <strong>Markdown</strong>.</p>\n",
"title": "Hello",
"headings": [{"level": 1, "text": "Hello", "id": "hello"}],
"wordCount": 4,
"tocHtml": "<nav class=\"toc\"><ul><li><a href=\"#hello\">Hello</a></li></ul></nav>",
"error": null
}

source is text#N (position in your list), the file URL, or dataset:ID#N (item number). A failed document has an empty html and an error such as http_404, timeout, blocked_private_address, document_too_large, empty_document or missing_markdown_field: markdown. A STATS record in the key-value store counts converted, failed (by reason) and charged documents.

FAQ

What exactly does sanitizing remove? Everything outside a safe list. Scripts, styles, iframes, forms, event-handler attributes (onclick, onerror), javascript: and data: links, and unknown attributes are dropped. Kept: normal text structure, links (http, https, mailto, tel and relative), images, tables, code, lists, footnotes and task-list checkboxes (always disabled). A Markdown link such as [x](javascript:...) is not turned into a link at all; it stays as plain, harmless text. Sanitizing is a safety net for text you did not write yourself. It is not a promise about the content of the links.

Should I turn sanitizing off? Only for Markdown you wrote and trust, when you need HTML the safe list does not allow. With it off, the HTML is passed through exactly as written, scripts included. Never turn it off for AI output, comments or any other outside text.

Which Markdown is supported? CommonMark plus tables, strikethrough, task lists and footnotes (switch gfm off for plain CommonMark). Bare URLs in a sentence are not turned into links automatically: write [text](url) or <url>. Math, diagrams, emoji shortcodes and syntax highlighting colors are not included; code blocks come out as <pre><code class="language-..."> for the highlighter of your site.

How does the table of contents work? Turn on toc. Each row gets tocHtml, a nested list of links to the heading ids, down to tocDepth. Set prependToc to also have it at the top of html. Documents without headings get an empty tocHtml.

What are the limits? 5,000 documents per run and 2 MB per document, fixed and not changeable in the input. A file is downloaded up to 50 MB and then counts as one document (so it must be 2 MB or less). Each URL is fetched with a 30-second timeout and retried up to 3 times on connection errors, timeouts and server errors (not on 404). Links to internal or private addresses are refused. More than 5,000 inputs: the first 5,000 are processed and the run says so.

What does it cost? $0.001 per converted document, nothing for failures and the demo. See Price above.

Which character encodings work for files? UTF-8 (with or without BOM) first, then the charset the server announces (for example Shift_JIS), otherwise UTF-8 with replacement characters.

Is my data stored? No. Texts, files and datasets are read, converted and written to your own run's dataset. Only the URLs you give are fetched, one request per file, and nothing is crawled.

Notes

Fetch only files you are allowed to read. You are responsible for the rights to the documents you convert and for the sites you point the Actor at.

More tools from the same developer