Skip to content

Syntax overview

AsciiChem is plain ASCII chemistry. Every construct is something a chemist can type on a standard keyboard. This page is the tour: every construct, one example each, links to the detail pages.

Source Rendered
H He C Fe Au
Install the asciichem gem to see this rendered.

Atom reference →

Source Rendered
H_2 H_2O H_2SO_4 C_6H_12O_6
Install the asciichem gem to see this rendered.

Multi-character subscripts use braces: H_{2a}.

Source Rendered
^14C ^131I ^238U
Install the asciichem gem to see this rendered.

The prefix binds to the following atom. Why this matters →

Source Rendered
Ca^2+ Cl^- SO_4^2- Fe^3+
Install the asciichem gem to see this rendered.

IUPAC canonical form: number-then-sign. +2 is normalised to 2+.

Source Rendered
Fe^(II) Fe^(III) Mn^(VII)
Install the asciichem gem to see this rendered.

Roman numerals in parens.

Source Rendered
2H_2O 3H_2 10CO_2
Install the asciichem gem to see this rendered.

Leading digits followed by an element or open bracket.

Source Rendered
Ca(OH)_2 (NH_4)_2SO_4 [Fe(CN)_6]
Install the asciichem gem to see this rendered.

Bracket variants (), [], {} are preserved through round-trip.

Source Rendered
H-O-H H_2C=CH_2 HC#CH Re##Re C>-H C-<H NH_3~>BF_3 A~~B
Install the asciichem gem to see this rendered.

Eight kinds: single, double, triple, quadruple, wedge, hash, dative, wavy. Bond reference →

Source Rendered
(R)-CH_3 (S)-CH(OH)COOH (E)-CH=CH (Z)-A=B (alpha)-C (β)-C
Install the asciichem gem to see this rendered.

Markers attach to molecules. Greek alpha/beta typed words are accepted alongside α/β. Stereo reference →

Source Rendered
:O ::O Cl. O=O..
Install the asciichem gem to see this rendered.

Prefix : for lone pairs; suffix . for radical electrons.

Source Rendered
2H_2 + O_2 -> 2H_2O HCl + NaOH -> NaCl + H_2O N_2 + 3H_2 <=>[Fe][400°C] 2NH_3
Install the asciichem gem to see this rendered.

Four arrow kinds: forward ->, reverse <-, equilibrium <=>, resonance <->. Conditions in [above][below] brackets. Reaction reference →

Source Rendered
A -> B -> C 2A -> 2B -> 2C A <=>[Fe][T] B -> C
Install the asciichem gem to see this rendered.

Multi-step chains promote to a single ReactionCascade. Cascade reference →

Source Rendered
1s^2 2s^2 1s^2 2s^2 2p^6 3s^2 3p^6 4s^2 3d^10
Install the asciichem gem to see this rendered.

Two or more orbital^occupancy pairs.

Source Rendered
`K_c = [P]/[R]` `x^2 + y^2` `rate = k[A]^2[B]`
Install the asciichem gem to see this rendered.

Backtick-delimited runs are parsed by Plurimath. Embedded math reference →

Real chemistry mixes everything:

Source Rendered
^14C_6H_12O_6 + 6O_2 -> 6CO_2 + 6H_2O `Delta G = -2870 kJ/mol`
Install the asciichem gem to see this rendered.

A radioactive glucose combustion with embedded thermodynamics.

Per-construct detail

Each syntax page has worked examples and round-trip behaviour. Start with Atoms.

The model

Every construct maps to a model class. See The model for the layer diagram and per-class reference.

IUPAC mapping

Every construct’s spelling traced to its IUPAC source. See IUPAC mapping.

Play