Skip to content

Start with Node.js

Render Markdown in a Node.js application with a synchronous, native API. Use Node.js 22.12 or newer. TypeScript declarations are included.

Install the release candidate

npm install ferromark@2.0.0-rc.1

V2 is in release-candidate testing. npm's stable latest channel stays on v1. Read the migration guide before upgrading.

Save this as example.mjs and run node example.mjs:

import { toHtml } from "ferromark";

const html = toHtml("# Hello\n\n**World**");
console.log(html);

The result is:

<h1 id="hello">Hello</h1>
<p><strong>World</strong></p>

For CommonJS, use const { toHtml } = require('ferromark') on a supported Node.js version. You do not need to install a compiler: npm selects a prebuilt native package for your platform.

Choose your API

Your taskAPIResult
Render one documenttoHtml(markdown, options?)HTML string
Send HTML as bytestoHtmlBuffer(markdown, options?)UTF-8 Buffer
Get HTML and metadatatransform(markdown, options?)HTML, headings, optional front matter
Render many documentsnew Renderer(options?)Reuses native parser scratch
Highlight codetoHtmlWithHighlighter()HTML with custom code-block output
Highlight and collect metadatatransformWithHighlighter()HTML, headings, optional front matter

These calls are synchronous. For sustained CPU work in a server, use a worker thread so rendering does not occupy the request-handling event loop.

Next: configure your content

Set rendering options, then build a content pipeline. For installation failures or server deployment, see runtime and deployment.