Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsMay 16, 2026·3 min de lecture

Showdown — Bidirectional Markdown to HTML Converter in JavaScript

Showdown is a JavaScript library that converts Markdown to HTML and back, running in both the browser and Node.js with extensive extension support for custom syntax.

Prêt pour agents

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Showdown
Commande CLI universelle
npx tokrepo install 4b972e9d-5166-11f1-9bc6-00163e2b0d79

Introduction

Showdown is one of the original JavaScript Markdown parsers, providing reliable bidirectional conversion between Markdown and HTML. It works identically in Node.js and browsers, making it suitable for both server-side rendering and client-side preview editors where you need to parse or generate Markdown on the fly.

What Showdown Does

  • Converts Markdown text to HTML with configurable flavor options
  • Converts HTML back to Markdown (reverse conversion)
  • Supports GitHub Flavored Markdown (tables, strikethrough, task lists)
  • Provides an extension system for adding custom syntax rules
  • Runs in any JavaScript environment without dependencies

Architecture Overview

Showdown processes Markdown in multiple passes: first normalizing input (tabs, line endings), then applying block-level grammar rules (headings, lists, blockquotes, code blocks), and finally inline-level rules (bold, italic, links, images). Each rule is a regex-based sub-parser that can be replaced or extended via the plugin system. The output is assembled as an HTML string without an intermediate AST.

Self-Hosting & Configuration

  • Install as an npm package or include the CDN script for browser use
  • Configure options globally via showdown.setOption() or per-converter instance
  • Enable GFM features with tables: true, strikethrough: true, tasklists: true
  • Set sanitize: true or use a separate sanitizer to prevent XSS in user content
  • Register custom extensions with showdown.extension('name', extensionFunction)

Key Features

  • Bidirectional conversion (Markdown to HTML and HTML to Markdown)
  • Works identically in Node.js and browser environments
  • Extensive option flags for GFM, metadata, emoji, and more
  • Plugin architecture for custom syntax extensions
  • Zero external dependencies and small bundle size (~40KB minified)

Comparison with Similar Tools

  • marked — marked is faster for one-way Markdown-to-HTML but lacks reverse conversion
  • markdown-it — markdown-it is plugin-rich and CommonMark-compliant; Showdown offers simpler bidirectional support
  • remark — remark uses an AST pipeline for transformations; Showdown is regex-based and simpler to configure
  • unified — unified is a full content processing ecosystem; Showdown is a focused single-purpose converter
  • Turndown — Turndown handles HTML-to-Markdown only; Showdown does both directions in one library

FAQ

Q: Is Showdown CommonMark compliant? A: Showdown follows the original Markdown spec with GFM extensions. It does not strictly follow CommonMark but handles most practical use cases correctly.

Q: Can I use Showdown for user-generated content safely? A: You should pair Showdown with a sanitizer like DOMPurify. Showdown's built-in sanitize option is basic and not recommended for untrusted input.

Q: How do I add custom syntax like :emoji: codes? A: Write a Showdown extension that defines regex patterns and replacements, then register it before creating the converter.

Q: Does Showdown support syntax highlighting in code blocks? A: Showdown renders code blocks as <pre><code> elements. Pair it with Highlight.js or Prism.js for syntax coloring.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires