Superscript and Subscript in Markdown
Standard Markdown has no superscript or subscript syntax, so <sup> and <sub> do the job: x<sup>2</sup>, H<sub>2</sub>O. This guide also covers math, Unicode characters and the shorthand some apps add.
Quick answer
How do you write superscript and subscript in Markdown?
Use the HTML tags <sup> and <sub>: x<sup>2</sup> raises the 2 and H<sub>2</sub>O lowers it. They work on GitHub and in most apps that allow HTML. Pandoc and Typora also read ^text^ and ~text~.
E = mc<sup>2</sup> and H<sub>2</sub>OResult
E = mc2 and H2O
Superscript and subscript examples
Pick the method by where the text will be shown.
Superscript with <sup>
For exponents, ordinals and reference marks.
10<sup>-3</sup> seconds, 1<sup>st</sup> place, a note<sup>1</sup>Result
10-3 seconds, 1st place, a note1
Subscript with <sub>
For chemical formulas and indexes.
CO<sub>2</sub>, x<sub>i</sub>, log<sub>2</sub> 8 = 3Result
CO2, xi, log2 8 = 3
Math notation
Where math is supported, ^ and _ inside dollar signs write proper formulas.
$x^2 + y^2 = r^2$ and $\mathrm{H_2O}$Result
and
Unicode characters
Superscript and subscript digits are ordinary characters, so they show up everywhere, chat apps included.
x² + y² = r², H₂O, 10⁻³Result
x² + y² = r², H₂O, 10⁻³
Nesting and formatting
The tags can hold Markdown and other tags, even each other.
2<sup>2<sup>2</sup></sup> = 16 and Price<sup>**new**</sup>Result
222 = 16 and Pricenew
Pandoc and Typora: carets and tildes
Pandoc reads ^text^ as superscript and ~text~ as subscript; Typora does once the options are on. On GitHub a single tilde means strikethrough.
x^2^ and H~2~OPandoc and Typora only. Other Markdown apps display this differently, so there is no preview.
Superscript and subscript in popular apps
The HTML tags work wherever inline HTML is kept.
| App | Support | Notes |
|---|---|---|
| GitHub / GitLab | Supported | <sup> and <sub> work; math with ^ and _ too. |
| Obsidian | Supported | <sup> and <sub> work in reading view. |
| Typora | Supported | The tags work, and ^text^ and ~text~ once turned on in the settings. |
| Notion | Not supported | No typed syntax; use an inline equation or Unicode characters. |
| Discord / Slack | Not supported | No superscript; Unicode characters such as ² still display. |
Questions and answers
Does Markdown have superscript syntax?
<sup> and <sub> where HTML is allowed; Pandoc and Typora also read ^text^ and ~text~.How do I write superscript on GitHub?
<sup>: x<sup>2</sup>. GitHub also renders math, so $x^2$ works as well.Why does ~text~ strike text through instead of lowering it?
~text~ strike text through instead of lowering it?<sub> for subscripts there.How do I write a chemical formula?
<sub>: H<sub>2</sub>O, or math: $\mathrm{H_2O}$. Unicode subscript digits such as ₂ also work in plain text.How do I add superscript in Discord or Slack?
Do superscripts survive a Word or PDF export?
<sup> and <sub> into Word superscript and subscript, and Markdown to PDF prints them.