How to Remove Markdown Formatting From Text
To remove Markdown formatting, delete the syntax characters and keep the words: the # in front of headings, the asterisks or underscores around emphasised words, the backticks and fences around code and, if you want, the markers in front of list items. What remains is ordinary plain text with the same wording and the same line structure.
In the Text Cleaner the AI Formatting preset does this, and each kind of marker has its own checkbox: headings and bold/italic in the Markup card under the Input Text box, code fences and list markers in the Markup group under Advanced Cleaning Options. A few kinds of Markdown are deliberately left alone, because removing them involves a choice that only you can make.
What each marker is and what removing it leaves
| Markdown | Example | After removal | Text Cleaner option |
|---|---|---|---|
| Heading | ## Setup |
Setup |
Remove Markdown heading markers |
| Bold | **done** or __done__ |
done |
Remove Markdown bold/italic markers |
| Italic | *soon* or _soon_ |
soon |
Remove Markdown bold/italic markers |
| Inline code | `npm test` |
npm test |
Remove Markdown code fences |
| Fenced code block | A line of three backticks above and below the code | The code lines on their own | Remove Markdown code fences |
| Bullet item | - milk |
milk |
Remove Markdown list markers |
| Numbered item | 2. eggs |
eggs |
Remove Markdown list markers |
Some detail behind the table:
- A heading in this style, which CommonMark calls an ATX heading, is one to six
#characters at the start of a line followed by a space. Without the marker it is an ordinary line, set apart only by the blank lines around it. - Emphasis markers come in pairs around a word or phrase: one
*or_on each side for emphasis (usually italics), two for strong emphasis (usually bold). - A fenced code block starts and ends with a line of at least three backticks or tildes, and the opening line may name a language. The whole fence line is removed, language label included. Inline code sits between backticks inside a sentence, and only the backticks go.
- Bullets can be
-,*or+. Numbered items are digits followed by.or). A typographic bullet such as•is not a Markdown marker and is not removed.
The heading, bold/italic and code options are what the AI Formatting preset switches on, in addition to the whitespace cleanup of General Clean. List markers stay unless you tick that option yourself.
The Plain Text preset uses the same three Markdown options and adds Strip HTML tags and Decode HTML entities. Markdown allows raw HTML, so documents often contain a stray <br> or . The catch is that Plain Text removes anything shaped like a tag, so a placeholder such as <your-name> disappears with it. An address in angle brackets, such as <https://example.com> or <name@example.com>, is recognised as an address and kept. For Markdown without HTML, AI Formatting is the safer choice. Converting HTML to plain text covers the HTML side.
Before and after
Before
## Release checklist
Run the **full** test suite before tagging. Use `npm test`, not the _quick_ script.
```
# bump the version
npm version patch
```
1. Tag the commit
2. Publish the notes
After
Release checklist
Run the full test suite before tagging. Use npm test, not the quick script.
# bump the version
npm version patch
1. Tag the commit
2. Publish the notes
This is the AI Formatting preset. The heading marker, the emphasis markers, the backticks and both fence lines are gone. The numbered steps are still numbered, and the line that begins with # inside the code block is untouched, for a reason covered below. The change summary reads “3 code markers removed”, “1 heading marker removed” and “2 bold/italic marker pairs removed”.
Where mechanical removal goes wrong
A remover matches symbols. It cannot tell what the author meant by them, so the same characters used for another purpose are at risk. In a few places, noted below, the Text Cleaner is deliberately more cautious than a Markdown renderer.
Asterisks that are not emphasis
Multiplication, footnote marks, wildcards and exponents all use asterisks. By CommonMark’s rules 2*3*4 is emphasis around the 3, and a renderer drops both asterisks. The Text Cleaner is stricter: a single * counts as an italic marker only when its outer side does not touch a letter (A to Z) or a digit, so 2*3*4, a*b*c and 2 * 3 * 4 all come through unchanged. A lone footnote mark (Free delivery*) or wildcard (*.csv) has no partner and is left alone as well.
The double asterisk follows the same rule, so exponents such as 2**8 and 3**2 and Python-style **kwargs come through unchanged. The price of that caution is that bold touching a letter or digit on its outer side, as in **bold**er, is left as it is. Horizontal rules made of asterisks are skipped entirely. What can still be caught is a pair of asterisks that sit against punctuation instead of letters: *.csv,*.txt comes out as .csv,.txt.
Underscores inside names
An underscore in the middle of a word cannot open or close emphasis, in CommonMark or in the Text Cleaner, so user_id_field is safe. Underscores at the edges of a word are different: __init__ written outside code formatting is, by the same rules, the word init in bold, and a file name such as _draft_ is draft in italics. Both lose their underscores when the bold/italic option runs. Compare any identifiers or file names that are not in backticks before and after.
A hash sign that is not a heading
A heading needs its # at the start of the line and a space after it. By that rule #launch and #42 are not headings, so a hashtag or an issue number at the start of a line is left alone. A line that starts with # and a space is a heading whatever the author intended. A shell comment pasted outside a code fence, or a note such as # of seats: 40, loses its hash sign.
List markers that carry meaning
Numbers in a procedure record the order, and other text may refer to them (“repeat step 2”). Remove the markers and that reference points at nothing.
Markdown’s list rules also catch lines that were never meant as lists. 1986. The factory opens. begins with digits and a period, which makes it a numbered item, and - 4 degrees overnight begins with a hyphen and a space, which makes it a bullet. With Remove Markdown list markers ticked, the year disappears from the first line and the minus sign from the second. This is why the option is off in every preset.
What counts as code
Inside a fenced block Markdown treats every character as literal, and code depends on the same symbols Markdown uses: # starts a comment in Python and shell scripts, * multiplies, underscores join the parts of a name. So every Markdown option skips the contents of fenced code blocks. With Remove Markdown code fences ticked the fence lines go and the lines between them come through as written, as the # bump the version comment did in the example.
Inline code is protected in a narrower way. Text between backticks is shielded from bold/italic removal, and the code option removes only the backticks: `**kwargs` becomes **kwargs, and `__main__` becomes __main__.
Code with neither a fence nor backticks has no protection. A bare def __init__(self): comes out as def init(self):, and indenting code by four spaces, Markdown’s other way of marking a code block, does not shield it from bold/italic removal.
Markdown the options leave in place
No option handles links, images, blockquotes, tables, horizontal rules, strikethrough or underline-style headings, so they stay in the text. Each needs a decision first. Find & Replace helps with several of them. It runs after the other cleaning steps and takes one pattern at a time, so press Move Result to Input between patterns.
- Links are written
[text](url). Decide whether to keep the text, the address or both. With Use regular expression ticked, finding\[([^\]]+)\]\(([^)]+)\)and replacing with$1keeps the text only, and$1 ($2)keeps both. The pattern is a rough instrument: an address that contains a closing parenthesis leaves a stray)behind, a link title ends up inside$2, and reference-style links such as[text][1]are not matched. - Images are links with a
!in front. Handle them before links, or the link pattern leaves the!behind. Find!\[([^\]]*)\]\([^)]+\)and replace it with$1to keep the description, or with nothing to delete the image. - Blockquotes put
>and a space at the start of each quoted line. Find^> ?and leave Replace with empty to remove one level of quoting from every line; in regular-expression mode^matches at the start of each line. For nested quotes, find^(> ?)+instead. - Tables are rows of cells divided by pipes, with a row of dashes under the header. Delete the dash row, then either rewrite the rows as sentences or replace the pipes with tabs and paste the result into a spreadsheet.
- Horizontal rules are lines made of three or more hyphens, asterisks or underscores. Underline-style headings have a row of equals signs or hyphens directly under the heading text and no
#to remove. Neither is removed, so delete those lines by hand. - Strikethrough, a GitHub extension written
~~text~~, is not among the markers the bold/italic option removes. Find~~and leave Replace with empty to delete the tildes.
The other route: render first, then copy
Instead of deleting syntax you can let a Markdown renderer interpret it: paste the text into something that displays Markdown, such as the preview pane of a code editor, select the rendered result, copy it, and paste it into the destination as plain text.
The renderer applies the whole grammar, so links shrink to their text and blockquote marks and rules disappear. In exchange, link addresses are lost, and whether bullets, numbers and table columns survive depends on the apps involved. The copy carries styling as well, so the paste has to be a plain-text paste; removing formatting without changing the words lists the ways to do that.
If the Markdown came from a chatbot answer, cleaning AI text formatting walks through that case, including the spacing and punctuation that tend to come with it.
Sources
- CommonMark Spec — CommonMark
- GitHub Flavored Markdown Spec — GitHub
This guide was drafted with AI assistance and reviewed by the publisher. See the editorial policy for how guides are written and corrected.