explaingit

russross/blackfriday

5,617GoAudience · developerComplexity · 2/5Setup · easy

TLDR

A Go library that converts Markdown text to HTML, safe for untrusted user input, with support for tables, fenced code blocks, strikethrough, autolinks, and a v2 API that produces an abstract syntax tree for custom rendering.

Mindmap

mindmap
  root((Blackfriday))
    What it does
      Markdown to HTML
      Safe for untrusted input
      Abstract syntax tree
    Extensions
      Tables
      Fenced code blocks
      Strikethrough
      Autolinks
    Versions
      v1 faster
      v2 cleaner API
      Custom renderers
    Setup
      Go module import
      No external deps
      CLI tool available
    Notes
      Pair with Bluemonday
      W3C validated output
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Render Markdown content submitted by users into HTML in a Go web application without crashing on malformed input.

USE CASE 2

Convert documentation Markdown files to HTML as part of a static site generator written in Go.

USE CASE 3

Parse Markdown into an abstract syntax tree to build a custom renderer or extract structured content.

USE CASE 4

Use the blackfriday-tool command-line tool to convert Markdown files to HTML without writing any Go code.

Tech stack

Go

Getting it running

Difficulty · easy Time to first run · 5min

No dependencies outside the Go standard library, add with go get and import directly into your project.

No license information is mentioned in the explanation.

In plain English

Blackfriday is a Markdown processor written in Go. It takes Markdown-formatted text as input and produces HTML output. Developers add it to Go projects as a library when they need to convert Markdown to HTML, such as for rendering user-written content in web applications or documentation tools. It was originally translated from a C project called Sundown. The library is designed to handle untrusted input without crashing. Blackfriday parsing is deliberately careful, so feeding it content from unknown users will not cause runtime failures. That said, the README notes that this safety applies to runtime stability only, not to JavaScript injection attacks in rendered output. For HTML sanitization of user content, the documentation recommends pairing Blackfriday with a separate library called Bluemonday. Blackfriday supports common Markdown extensions beyond the basic spec, including tables, fenced code blocks, autolinks, strikethrough text, and suppression of emphasis markers inside words (useful for code identifiers). HTML output is validated against W3C standards for HTML 4.01 and XHTML 1.0. It has no dependencies outside the Go standard library, which makes it easy to include in any Go project. The recommended version is v2, available at the /v2 import path. Version 2 has a cleaner API and introduces a separate parsing step that produces an abstract syntax tree, making it easier to add custom rendering. A drawback noted in the README is that v2 is about 15% slower than v1. The older v1 remains available for projects that cannot update to the new API. A companion command-line tool called blackfriday-tool is available for converting Markdown files directly from the terminal without writing any Go code.

Copy-paste prompts

Prompt 1
Show me how to add Blackfriday v2 to my Go module and render a user-submitted Markdown string to HTML, then chain it with Bluemonday to strip any XSS payloads from the output.
Prompt 2
I want to write a custom Blackfriday v2 renderer that wraps every code block in a div with a copy-to-clipboard button. Show me the renderer interface I need to implement.
Prompt 3
Use the blackfriday-tool CLI to convert a folder of Markdown documentation files to HTML as part of a Makefile build step.
Open on GitHub → Explain another repo

← russross on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.