Use remark to covert markdown into HTML

I’ve used remark in a few different projects, and each time I found it difficult to get started. For such a popular project, the documentation is quite terse.

To save myself the trouble of looking up how to do it in the future, here are the basic steps you need to get started converting markdown to HTML with remark.

First, install remark dependencies:

npm i remark remark-html

We will need the core library and a plugin for generating HTML. Then, import your dependencies and use them like so:

import remark from 'remark'
import remarkHTML from 'remark-html'

const html = remark()
.processSync('Some **markdown** text')

That’s all you need to get going. To help jump-start your progress, checkout this working repl in Node.js or sandbox in React.

Hope this guide helps you get up and running too!

Happy coding!

Acts 12:25 (SDG)

About the author

My name is Sean McPherson, and I am a software engineer interesed in all areas of front-end development. Here I write articles about programming for developers of all levels, and occassionally other topics.

Currently I work for and live with my lovely family in Pittsburgh, PA.