Articles
Published · November 8, 2026

Superscript and Subscript in Markdown: What's Actually Supported

Markdown has no native superscript or subscript syntax. Here is what GFM, HTML tags and Pandoc's ^ and ~ shorthand do, and how to test your renderer.

Also in: Español中文हिन्दी

Introduction

Markdown has no superscript or subscript syntax of its own. To get 2<sup>10</sup> or H<sub>2</sub>O, you either write HTML tags or rely on an extension that only some tools turn on.

That gap trips up anyone who moves footnoted or scientific notes between apps: you type 2^10^ or H~2~O, one tool renders it, and the next prints the symbols as they are. This article covers what the specs say, the HTML fallback, Pandoc's shorthand, and a quick way to test your own setup.

What the specs say about markdown superscript subscript syntax

The GitHub Flavored Markdown spec defines no superscript or subscript syntax. Its table of contents has no entry for either. If you want the background on why the core stays small, how Markdown got a spec covers the road from Daring Fireball to CommonMark.

What the spec does have is raw HTML. Text between < and > that looks like an HTML tag is parsed as a raw HTML tag, and an HTML block is passed through without being escaped in the output. That is the loophole every Markdown writer uses for superscripts.

The HTML fallback: sub and sup tags

GitHub's own docs show the approach. Subscript and superscript use <sub> and <sup>, in comment fields and in .md files:

Water is H<sub>2</sub>O.
Two to the tenth is 2<sup>10</sup>, or 1024.

This is the most portable option. The tags travel with the text and any renderer that passes HTML through will show them.

The catch is the renderer. GitHub's page names the tags that work but does not say which HTML it sanitizes or strips, and other tools make their own choices. Some escape raw HTML entirely, and then your note shows literal <sup> text. If a tool does that, look for an HTML setting, or fall back to Unicode characters such as ² and ₂ for short, simple cases.

Pandoc's caret and tilde shorthand

Pandoc offers a non-HTML shorthand through its superscript and subscript extensions. Wrap text in ^ for a superscript and in ~ for a subscript:

H~2~O is a liquid. 2^10^ is 1024.

One rule to remember: the text between the delimiters cannot contain spaces or newlines. If it does, escape each space with a backslash. Pandoc's own example is P~a\ cat~, not P~a cat~.

This syntax belongs to Pandoc's Markdown. Paste H~2~O into a plain CommonMark or GFM renderer and you will see the tildes. The same split shows up with footnotes, which you can see in Markdown footnotes compared across GFM and Pandoc. Use the shorthand only in a pipeline you control end to end, such as Markdown files you convert with Pandoc.

When to use them

MDN says `<sup>` should only be used for typographical reasons: to follow typographic conventions, not just for looks. Its examples are exponents (x³), superior lettering (M<sup>lle</sup>) and ordinal numbers (5<sup>th</sup>). Raised text for a styled wordmark belongs in CSS, not in a tag.

Two limits to know:

  • <sub> and <sup> cannot be combined on a single symbol. An atomic number stacked over a mass number needs MathML's <msubsup>.
  • For complex exponents and formulas, MDN points to MathML rather than a pile of nested tags.

For a footnote marker, a Markdown footnote is usually the better tool than a hand-typed superscript number.

Choosing between the three options

Pick by where the text will end up, not by which syntax looks cleanest in the source.

  • Notes that may open in any app: use <sub> and <sup>. They are longer to type, but a tool that ignores them still shows readable text, such as H<sub>2</sub>O, rather than stray punctuation.
  • A document you export with Pandoc: the ^ and ~ shorthand is shorter and easier to read in the source. Keep the backslash rule in mind for anything with a space.
  • A short, one-off mark in a message or commit note: a Unicode character like ² is often enough. It has no markup to break. It only covers a limited set of characters, so longer expressions still need a tag.

Mixing the first two in one file is a trap. A renderer that handles only one of them leaves the other as visible symbols, so choose one per project and write it down at the top of the file.

Testing in your own renderer

Paste these three lines into the tool you use and preview them:

H<sub>2</sub>O
2<sup>10</sup>
H~2~O

If the first two render, your tool passes HTML through. If the third renders too, a Pandoc-style extension is on. Anything that shows as raw symbols tells you which flavor you are dealing with. Tables are another feature that varies between tools, and Markdown tables explains how to write them safely.

How Carets fits in

Whichever syntax you pick, your notes stay plain text, so <sup> tags and ^ markers remain readable in the source and portable to any other tool. Carets is a fast, native notes and code editor for iPhone, iPad and Mac. It handles Markdown, plain text and code in one place, with syntax highlighting, and organizes files into projects and tags. That helps when you keep a test file like the one above next to the notes it protects. Carets is on the App Store for iPhone, iPad and Mac.

Frequently Asked Questions

Does Markdown have superscript syntax?

Not in the core syntax. The GFM spec defines none, so in most renderers you write the HTML <sup> tag. Pandoc's Markdown adds ^text^ as an extension.

How do I write H2O in Markdown?

Write H<sub>2</sub>O where HTML passes through, or H~2~O in Pandoc.

Why does my superscript show up as literal tags?

The renderer is escaping or stripping raw HTML. Check its HTML setting, or use a Unicode superscript character instead.

Can I put a subscript and a superscript on the same character?

Not with <sub> and <sup> alone. MDN points to MathML's <msubsup> for stacked scripts.