remove-markdown
A zero-dependency Node.js library that strips Markdown formatting down to clean plain text.
Repository Health
Technical Analysis
remove-markdown is a small, dependency-free Node.js module that strips Markdown syntax out of a string, leaving behind plain, readable text. It targets the full range of common Markdown constructs — headers, emphasis, links, images, blockquotes, list markers, fenced code blocks, GitHub-Flavored Markdown strikethrough, and embedded HTML tags — collapsing them into their underlying text content rather than deleting it outright.
The library is commonly reached for when an application needs to show a Markdown-authored post, comment, or note somewhere that can’t (or shouldn’t) render Markdown: list previews, search result snippets, push notifications, RSS feed summaries, or plain-text email digests. It ships a small options object for tuning behavior — replacing links with their URL, preserving specific HTML tags, or customizing list-leader handling — and a bundled TypeScript declaration file for typed usage out of the box.
What You Get
- A single synchronous
removeMd(markdown, options)function with zero runtime dependencies to install or configure - Coverage for the common Markdown surface: ATX and setext headers, emphasis/strong, blockquotes, list leaders, horizontal rules, inline and fenced code, images, links, footnotes, and reference-style links
- GitHub-Flavored Markdown extras out of the box — strikethrough (
~~text~~) and fenced code block stripping — toggleable via thegfmoption - Fine-grained options:
useImgAltTextto keep image alt text,replaceLinksWithURLandseparateLinksAndTextsto control link output,htmlTagsToSkipto allowlist specific HTML tags instead of stripping them, andthrowErrorto opt into exceptions instead of silent fallback - A bundled
index.d.tsTypeScript declaration, so consumers get typed options and return values without an extra@typespackage
Common Use Cases
- Generating a plain-text excerpt or teaser from a Markdown blog post for a listing page or card
- Producing clean summaries for search indexes (Algolia, Elasticsearch, Meilisearch) from Markdown-authored content so results don’t show raw syntax
- Building plain-text push notifications, SMS, or email digests from Markdown source (e.g. a comment or changelog entry)
- Sanitizing Markdown-formatted user input before feeding it to text-only surfaces like meta descriptions, social share previews, or voice assistants
Under The Hood
Architecture remove-markdown is a single exported function, module.exports = function(md, options), defined entirely in index.js. It runs the input string through a deliberately ordered chain of String.replace() calls: horizontal rules are stripped first (explicitly ordered ahead of list-leader stripping to avoid a regex conflict noted in a code comment), then list leaders, GFM constructs (setext headers, strikethrough, fenced code), abbreviations, HTML tags (built dynamically as a negative-lookahead regex when htmlTagsToSkip is set), links/images/footnotes/blockquotes, atx-style headers, emphasis markers, and inline code. The whole transform chain is wrapped in a single try/catch — on error it either rethrows (when options.throwError is set) or logs to console.error and returns the original, unmodified input, giving callers a safe-by-default fallback rather than a thrown exception. There is no internal module boundary, class hierarchy, or state; execution is a single synchronous pass with no async paths.
Tech Stack The library is plain, dependency-free JavaScript (CommonJS module.exports) with no runtime dependencies at all — package.json lists only devDependencies (chai, mocha, should) used for testing. There is no build step or bundler: the file published to npm (index.js) is the exact source that executes, and TypeScript support is provided by a separately hand-maintained index.d.ts rather than being generated from typed source, so the two can in principle drift out of sync.
Code Quality test/remove-markdown.js contains 264 lines of Mocha/Chai specs covering list stripping, HTML stripping, headers, emphasis, links, images, blockquotes, and the htmlTagsToSkip option, including edge cases like unmatched markdown characters — solid behavioral coverage for a single-function library. There is no linter configuration in the repo and no TypeScript source (only the hand-written declaration file), so type safety is external to the implementation. Naming is terse and regex-driven, which suits the file’s narrow, single-purpose scope; error handling is intentional rather than incidental, via the try/catch plus configurable throwError.
API Design The public surface is a single function, removeMd(markdown, options), which is about as low-boilerplate as an integration gets — const removeMd = require('remove-markdown') and one call. Sensible defaults (gfm: true, stripListLeaders: true, useImgAltText: true) mean zero-config usage already covers the common case, while nine well-documented options in the README cover the less common ones. Naming across options is slightly inconsistent (stripListLeaders vs. useImgAltText vs. abbr), and interactions between options like replaceLinksWithURL and separateLinksAndTexts aren’t explicitly documented, but the overall surface remains small and easy to pick up.
Used by 10 apps in this directory
Cal.diy
Scheduling
The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.
Cherry Studio
AI Assistants
All-in-one AI desktop client with 300+ assistants and multi-model support
Flowise
Developer Tools · Automation · No Code Platforms
Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.
Gotify
Monitoring · Developer Tools
A lightweight, self-hosted push notification server that sends and receives messages in real time over WebSocket, with a sleek web UI and a native Go plugin system.
highlight.io
Developer Tools · Analytics · Monitoring
Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.
LobeHub
AI Assistants · Productivity · Automation
Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.
Postiz
Social Media · Automation
The agentic social media scheduler — AI-powered content creation, 33-platform posting, and team workflows, all self-hosted.
Teable
Databases · No Code Platforms
A no-code PostgreSQL database with spreadsheet UX, real-time collaboration, and native AI agents — built for teams that outgrow Airtable.
Tianji
Analytics · Monitoring
Replace Google Analytics, UptimeKuma, and Prometheus with one self-hosted platform that tracks websites, monitors uptime, and reports server health.