Markdown cheatsheet · Superscript & subscript

Superscript and subscript in markdown

Core markdown cannot raise or lower text. The portable answer is plain HTML, <sup> and <sub>; Pandoc has a shorthand of its own.

The HTML tags (the portable route)

Markdown passes inline HTML through wherever the renderer allows it, so <sup> for superscript and <sub> for subscript are the closest thing to a standard.

You type
E = mc<sup>2</sup>

H<sub>2</sub>O
You get

E = mc2

H2O

GitHub strips most raw HTML during sanitization, but <sup> and <sub> are both on its allowlist, so this works in READMEs, issues, pull requests and comments. It also survives conversion to HTML untouched. The tags only fail in pipelines that strip inline HTML entirely; for those, see the Unicode fallback below.

Pandoc's shorthand

Pandoc wraps superscript in carets and subscript in single tildes.

You type
2^10^ is 1024.

H~2~O is a liquid.
You get (in Pandoc)

210 is 1024.

H2O is a liquid.

The text between the markers may not contain spaces or newlines; if you need one, escape it with a backslash: P~a\ cat~. The syntax belongs to Pandoc and tools built on it (Quarto, R Markdown), not to CommonMark or GFM.

The tilde collision: pasting H~2~O into GitHub does not just leave it literal. GFM's strikethrough extension matches "one or two tildes", so GitHub renders the 2 struck through instead of lowered. Renderers that insist on double tildes for strikethrough show the tildes as plain text. Either way, no subscript.

Unicode fallback

Chat apps and other plain-text contexts strip HTML and know no extensions. There you can use the characters themselves: x², H₂O, m³. Your OS character picker has them (Ctrl+Cmd+Space on macOS, Win+. on Windows; search for "superscript").

SetCharacters
Superscript⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁺ ⁻ ⁿ
Subscript₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₊ ₋

Digits are fully covered; letters are patchy (there is no complete subscript alphabet). And since these are distinct characters, searching your notes for "m3" will not match "m³".

Common questions

Does GFM have native superscript or subscript syntax?

No. GFM extends CommonMark with tables, task lists, strikethrough and autolinks; nothing raises or lowers text. The HTML tags are the supported route. If what you actually want is a numbered note marker, use footnotes instead.

How does Reddit do it?

With its own rule, not standard markdown: a caret superscripts the single word that follows it (^word), and ^(several words) groups a phrase. Reddit has no subscript at all, and neither caret form works anywhere else.

Related syntax

· All markdown guides

Less syntax. More writing.

Download maxdown

Free · no account · macOS, Windows & Linux