Skip to content

Reaction

A reaction captures a chemical transformation: reactants, an arrow type, products, and optional conditions rendered above and below the arrow per IUPAC.

FieldTypeSourceExample
reactantsArray of Moleculeleft of arrow2H_2 + O_2
productsArray of Moleculeright of arrow2H_2O
arrowSymbolarrow token:forward, :equilibrium, …
conditionsConditions struct[above][below]Conditions(above: "Fe", below: "400°C")
SymbolASCIIUnicodeUse
:forward->Net forward
:reverse<-Net reverse
:equilibrium<=>Equilibrium (Haber, acid/base)
:resonance<->Resonance structures
┌───────────────┐
│ Reaction │
│ │
reactants[0] ─┐ │
reactants[1] ─┤── left │ above
... ─┘ │ ▲
──────────►│ ──── ⇌ ────
│ ▼
products[0] ─┐ │ below
products[1] ─┤── right │
... ─┘ │
└───────────────┘

Conditions sit in bracketed groups immediately after the arrow. The first bracket is the above condition (catalyst), the second is the below condition (temperature / pressure / solvent).

N_2 + 3H_2 <=>[Fe][400°C] 2NH_3
N 2 + 3 H 2 Fe 400°C 2 N H 3

produces Conditions(above: "Fe", below: "400°C").

reaction := terms arrow terms
terms := molecule ("+" molecule)*
arrow := "<=>" | "<->" | "->" | "<-"
(with optional [above] and [below] conditions)
FormatterArrow renderingConditions
MathML<mo>⇌</mo> (or <mover>/<munderover> with conditions)<mtext>
TextASCII spelling[above][below]
HTMLUnicode arrow<sup> / <sub> around the arrow
LaTeXmhchem arrow[above][below] (mhchem native)
SVGASCII arrow[above][below]
AsciiChem.parse("2H_2 + O_2 -> 2H_2O").to_text # => "2H_2 + O_2 -> 2H_2O"
AsciiChem.parse("N_2 + 3H_2 <=>[Fe][400°C] 2NH_3").to_text # => same
AsciiChem.parse("HAc <=> Ac^- + H^+").to_text # => same
  • BalanceCheck — atom counts must match on both sides, respecting coefficients and group multiplicities.

Single-step reactions stay as Reaction. Two or more reactions chained (A -> B -> C) promote to a ReactionCascade.