gitmyhub

marked

JavaScript ★ 37k updated 5d ago

A markdown parser and compiler. Built for speed.

Marked is a fast JavaScript library that converts Markdown text into HTML with no dependencies. Use it in browsers, Node.js, or from the command line for blogs, documentation sites, and comment systems.

JavaScriptnpmsetup: easycomplexity 2/5

Marked is a fast, lightweight JavaScript library that converts Markdown text into HTML. Markdown is a plain-text writing format where you use simple symbols — like # for headings, ** for bold, or - for bullet lists — and Marked's job is to parse that text and produce the equivalent HTML code that browsers can render. The problem it solves is the universal need to turn human-readable text formatting into web-ready HTML without writing a full parser from scratch.

The library is built as a low-level compiler, meaning it processes Markdown line by line without building an intermediate syntax tree that needs to be held in memory, which keeps it fast and memory-efficient. It supports the most common Markdown flavors: the original Markdown specification, CommonMark (a standardized, unambiguous version), and GitHub Flavored Markdown (GFM), which adds features like strikethrough, tables, and task lists. The library is extensible — you can plug in custom tokenizers and renderers to handle your own syntax rules. One important note: Marked does not sanitize the HTML it produces, so if the Markdown source comes from untrusted users, you need to run the output through a separate sanitization library like DOMPurify before injecting it into a web page.

You would use Marked when building a blog, documentation site, comment system, or any application where users write in Markdown and you need to display it as HTML. It works in the browser (loaded via a script tag or ES module), as a Node.js library in a server-side application, or as a command-line tool for batch converting Markdown files. The tech stack is pure JavaScript with no runtime dependencies, distributed as an npm package under the MIT license.

Where it fits