Strip Markdown

Remove Markdown formatting and return plain text.

Code

General
markdown
  .replace(/^#{1,6}\s+/gm, '')           // Headers
  .replace(/\*\*(.+?)\*\*/g, '$1')       // Bold
  .replace(/\*(.+?)\*/g, '$1')           // Italic
  .replace(/__(.+?)__/g, '$1')           // Bold alt
  .replace(/_(.+?)_/g, '$1')             // Italic alt
  .replace(/`{3}[\s\S]*?`{3}/g, '')      // Code blocks
  .replace(/`(.+?)`/g, '$1')             // Inline code
  .replace(/\[(.+?)\]\(.+?\)/g, '$1')    // Links
  .replace(/!\[.*?\]\(.+?\)/g, '')       // Images
  .replace(/^\s*[-*+]\s+/gm, '')         // List items
  .replace(/^\s*\d+\.\s+/gm, '')         // Numbered lists
  .replace(/^\s*>/gm, '')                // Blockquotes
  .replace(/---/g, '')                   // Horizontal rules
  .trim();

Parameters

Markdown text

Browser·fetch() may be limited by CORS

More JavaScript Snippets