Skip to content

Markdown Character Count: Source vs. Rendered Text

Count raw Markdown when a limit applies to its source. For a limit on rendered paragraph text, render it first and select that paragraph's text. Formatting marks and link destinations can disappear from that result. Keep the counting unit separate from the rendering step.

Five exact source and paragraph counts

These inline cases were checked in the CommonMark reference renderer with smart punctuation disabled and no trailing input newline. Both counts use JavaScript UTF-16 units. The paragraph count measures its textContent after rendering; it excludes the HTML wrapper spelling and any newline added when serializing that HTML.

Markdown sourceSource unitsParagraph textParagraph units
**go**6go2
[go](/help)11go2
\*2*1
`*go*`6*go*4
**é😀**7é😀3

Under the CommonMark syntax rules, strong-emphasis delimiters and a link destination are not the paragraph's text. The escaped asterisk becomes a literal asterisk. In the code-span row, the asterisks remain literal text inside the code. Removing every asterisk would change that value rather than reproduce the parser's result.

Unicode still changes the counting unit

JavaScript string length counts UTF-16 code units. In é😀, the precomposed accented letter occupies one unit and the emoji occupies two. The paragraph therefore has three units, even though it contains two code points. A destination that measures another unit can report a different number for the same text.

Define whitespace and editor behavior

textContent extracts a node's descendant text. It is not a universal definition of visible text or clipboard output. Choose the intended paragraph rather than the whole page, where navigation or hidden content can enter the result. For a document with several blocks, define how separators and line breaks are counted before combining them.

Markdown implementations can also have different dialects. GitHub Flavored Markdown specifies extensions including tables and strikethrough. Check the actual editor or exporter used by the receiving system; the five inline checks above do not certify every editor's count or its copied whitespace.

Use the counter with the intended input

The Count Character counter uses JavaScript string length for its with-spaces character total. It counts the pasted text without rendering Markdown first. Paste the literal source for a source-text rule, or paste the intended paragraph's plain text for that text rule. Inspect extra line breaks introduced by copying. These character counts are not an upload-size check.

Use the String Length guide to compare counting units. The HTML character-count guide covers the separate difference between serialized HTML and DOM text.