# 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.
## Install
Save as a script file and run:
# Showdown — Bidirectional Markdown to HTML Converter in JavaScript
## Quick Use
```bash
# Install via npm
npm install showdown
# Node.js usage
# const showdown = require('showdown');
# const converter = new showdown.Converter();
# const html = converter.makeHtml('# Hello World');
# Browser via CDN
#
# Reverse: HTML to Markdown
# const md = converter.makeMarkdown('
Hello
');
```
## 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 `` elements. Pair it with Highlight.js or Prism.js for syntax coloring.
## Sources
- https://github.com/showdownjs/showdown
- http://showdownjs.com
---
Source: https://tokrepo.com/en/workflows/asset-4b972e9d
Author: Script Depot