How Does Strip Markdown Convert Markdown to Plain Text?
The engine runs 9 ordered regular expressions that remove structural markers (#, >, ---, ![]()) and unwrap inline formatting (**, __, *, `, [text](url)) while keeping the readable prose intact.
Markdown is the universal standard for technical writing, but publishing to plain-text mediums (such as email newsletters, SMS, or plain text forms) requires removing formatting syntax. Text Cleaner cleanly strips headers (#), bold (**), italics (*), blockquotes (>), horizontal rules, and keeps the visible link text while removing the URLs.
What Are the 9 Regex Rules & Worked Before / After Example?
Unlike naive symbol removers that delete all asterisks or brackets indiscriminately, Text Cleaner matches paired Markdown constructs and extracts the inner capture group ($1):
- Worked Before / After Example: Input
# Main Heading\n\nThis is **bold** text and *italic* text with [a link](https://acme.com) and `inline code`.\n\n> Blockquote here.(126 characters, 19 words, 5 lines) → OutputMain Heading\n\nThis is bold text and italic text with a link and inline code.\n\nBlockquote here.(94 characters, 17 words, 5 lines; 32 Markdown syntax characters removed).
| Markdown Construct & Regex Rule | Input Example (Before) | Output Result (After) | Syntax Chars Stripped (count) |
|---|---|---|---|
ATX Headings (s/^[ \t]{0,3}#{1,6}[ \t]+//gm) |
### Section Title (17 chars) |
Section Title (13 chars) |
-4 heading chars (### ) |
Bold & Italic (s/\*\*([^*]+)\*\*/$1/g, s/\*([^*]+)\*/$1/g) |
This is **bold** and *italic* (29 chars) |
This is bold and italic (23 chars) |
-6 asterisk chars |
Inline Links (s/\[([^\]]*)\]\([^)]*\)/$1/g) |
Read [our docs](https://acme.com) (33 chars) |
Read our docs (13 chars) |
-20 URL/bracket chars |
Images (s/!\[[^\]]*\]\([^)]*\)//g) |
Logo:  (22 chars) |
Logo: (6 chars) |
-16 image tag chars |
Blockquotes & Code (s/^[ \t]{0,3}>[ \t]?//gm, s/`([^`]+)`/$1/g) |
> Run `npm test` now (20 chars) |
Run npm test now (16 chars) |
-4 syntax chars (> and `) |