MolScript: A Text Language for Reaction Schemes and Curly-Arrow Mechanisms

Published: 17 Oct 2026 · Author: Scidart Academy · Reading time: ~14 min
Six lines of MolScript in a dark code panel beside the SN2 step they draw: hydroxide attacking bromomethane with two curly arrows
Six lines of MolScript draw a complete SN2 step: structures, charges, conditions and both curly arrows.

Short answer: MolScript is a small text language for reaction schemes and electron-pushing mechanisms. You write each species as SMILES, join species with +, ->, <-> or <=>, tag the atoms an arrow touches with atom-map numbers, and write one move line per curly arrow. MolDraw draws the structures, conditions, lone pairs, charges and every arrow, and checks each arrow against drawing rules before you see it. The result is ordinary, editable canvas content that you can download as an image or as chemfig code for LaTeX.

MolScript at a glance

What you writeSpecies as SMILES, operators between them, conditions in brackets after an arrow, and move lines for the electrons.
What you getA laid-out scheme: structures, plus signs, reaction, equilibrium or resonance arrows, conditions, captions, lone pairs, charges, radical dots and curly arrows.
Arrow typesTwo-electron curly arrows (->) and one-electron fish-hooks (~>), from lone pairs, charges, radicals, atoms or bonds, to atoms, bonds or bonds being formed.
CheckingEvery map number must exist and be unique; every arrow must start where electrons are; every drawn arrow is judged for gaps, aim, curvature and clearance. Problems come back with line numbers.
OutputEditable MolDraw canvas objects; every MolDraw export, including chemfig (.tex) for LaTeX documents.
Where it is used todayThe MolDraw AI chat draws mechanisms by writing MolScript, and the mechanism figures in the Templates panel are built from it.
What is nextAn open framework for canvas apps and an AI skill any assistant can load. See the roadmap.

Your first script: SN2

Hydroxide attacks bromomethane from the back and bromide leaves in the same step. In MolScript that is four lines:

title: SN2 of bromomethane
[OH-:1] "hydroxide" + [CH3:2][Br:3] "bromomethane" ->[SN2][acetone] CO "methanol" + [Br-]
move :1 -> 1..2
move 2-3 -> 3
SN2 of bromomethane drawn from MolScript: a curly arrow from the hydroxide charge to the carbon and a second from the C–Br bond to bromine, with SN2 above and acetone below the reaction arrow
Drawn by MolDraw from exactly the four lines above.

Line by line:

  1. title: puts a heading above the scheme.
  2. The scheme line lists the species. [OH-:1] is hydroxide whose oxygen carries map number 1; [CH3:2][Br:3] is bromomethane with the carbon as 2 and bromine as 3. "hydroxide" is a caption drawn under the structure. ->[SN2][acetone] is a reaction arrow with text above and below.
  3. move :1 -> 1..2: the lone pair (here the negative charge) on atom 1 goes to the bond being formed between 1 and 2.
  4. move 2-3 -> 3: the electrons of the existing C–Br bond go to bromine.

Map numbers are labels for you and the arrows. They are never drawn, and they do not change the molecule.

The language

Species and operators

Any SMILES is a species. Operators are written with a space on each side:

+Plus between co-reactants or co-products. Species joined by + always stay on one row.
->Reaction arrow.
<=>Equilibrium arrow (two half-headed arrows).
<->Resonance arrow (double-headed). Use it between resonance forms of one species.
=>Retrosynthesis arrow.

Text above and below an arrow goes in square brackets glued to it: ->[NaBH4][MeOH, 0 °C]. Leave the first pair empty for text below only: ->[][reflux]. A caption in double quotes after a species is drawn under that species: CC(=O)O "acetic acid".

Several steps

A line that starts with an operator continues the scheme from the last species, so a mechanism reads one step per line, with that step's arrows right under it:

title: SN1 of tert-butyl bromide
C[C:1](C)(C)[Br:2] ->[slow] C[C+:3](C)C + [Br-]
move 1-2 -> 2
-> C[C+:4](C)C + [OH2:5]
move :5 -> 5..4
->[fast] CC(C)(C)[OH2+]
Two-step SN1 mechanism drawn from MolScript: ionisation to the tert-butyl cation with the C–Br bond breaking onto bromine, then water attacking the carbocation
Rows wrap only at reaction arrows. The arrow that carries the scheme to the next row is one of the things the roadmap improves.

Curly arrows: move lines

Every atom an arrow touches gets a map number in the SMILES: [OH-:1], [CH3:2][Br:3], [O:4] for a plain oxygen. Numbers must be unique across the whole script. Then:

move <from> -> <to>     two-electron curly arrow
move <from> ~> <to>     one-electron fish-hook

Both ends are written the same way:

:nThe lone pair on atom n. On an anion the arrow starts at its minus sign, as chemists draw it.
nAtom n. A radical's arrow starts at its dot.
n-mThe existing bond between atoms n and m. As a start, its electrons leave the bond; as an end, they make the bond a double bond.
n..mA bond being formed between n and m (end only). The head stops beside atom m, on the side facing n.

Several arrows can share a line, separated by semicolons: move :1 -> 1..4; 4-2 -> 2-3; 3-5 -> 5. Write a transferred hydrogen explicitly, [H:5][O:6]CC, so an arrow can start from its bond. Write a mapped radical centre with its hydrogen count so it keeps its dot: CC(C)(C)[OH0:1] is the tert-butoxyl radical.

Arrows are placed automatically. When you want a particular bend, add an override in braces: move 2-3 -> 3 {bow=0.3 side=left}.

Directives and comments

title: …Heading above the scheme.
per-row: 2 to 8Structures per row before the scheme wraps (default 4).
layout: row, cycle, branchScheme shape: left to right, a catalytic cycle, or one reactant to several products.
# …Comment to the end of the line. A # inside SMILES (a triple bond) is not a comment.

Errors

Problems come back with the line they are on, in plain words, so a person or an AI assistant can fix the line and draw again:

line 1: put +, -> or <-> between "[O:1]C" and "[O:1]C"
line 3: no atom is tagged :9 in the SMILES (write it as [X:9])
line 4: n..m (a bond being formed) can only be the destination
line 5: a move needs -> (curly arrow) or ~> (fish-hook) between its ends
C (map 2) has no lone pair

How a script becomes a drawing

A script goes through the same steps every time, so the same script always gives the same drawing:

  1. Read. The script is split into scheme lines, move lines and directives. Each species, operator, caption and set of conditions is recorded with its line number.
  2. Check the labels. Every map number used in a move must be on exactly one atom, every n-m must be a real bond, and every start must have electrons to give: a lone pair, a charge, a radical or a bond.
  3. Draw the species. Each SMILES becomes a 2D structure with clean bond angles. Explicit hydrogens that an arrow needs are drawn as atoms; charges, lone pairs and radical dots are added where the SMILES says.
  4. Lay out the scheme. Structures, plus signs and arrows are packed by their real widths, rows wrap at reaction arrows, and conditions and captions are spaced so no text overlaps.
  5. Place the curly arrows. Each arrow leaves its source where a chemist would draw it and bends away from bonds, labels and other arrows (details below).
  6. Judge every arrow. Each placed arrow is measured against the rules. An arrow that could not meet them in a crowded spot is still drawn and reported as a warning.
  7. Hand over editable objects. The result is ordinary canvas content: drag a structure and its arrows follow, restyle anything, and export.

The arrow rules MolScript applies:

TailOn the lone pair or minus sign, the radical dot, or the middle of the bond that gives the electrons, never on top of an atom label.
HeadJust short of the atom that receives the electrons, or in the gap of a bond being formed, on the side facing the attacking atom.
CurveBowed to the outside of the structure, with one constant head angle; fish-hooks keep their single barb on the outside of the curve.
ClearanceKept away from bonds, labels, charges, dots and other arrows; arrows that share a target fan out instead of stacking.
LengthToo short to read or too long to follow is flagged.

Every reference mechanism in MolScript's test set is drawn and judged against these rules whenever MolDraw changes. Today that is 22 mechanisms with 46 curly arrows, all passing, plus the Templates figures.

Worked examples

E2 elimination: three arrows in one step

title: E2 elimination
[OH-:1] + [H:4][CH2:2][CH:3](C)[Br:5] ->[E2] C=CC + O + [Br-]
move :1 -> 1..4; 4-2 -> 2-3; 3-5 -> 5
E2 elimination drawn from MolScript: hydroxide takes the hydrogen, the C–H bond becomes the C=C π bond and the C–Br bond breaks onto bromine
The base takes the hydrogen, the C–H electrons become the new π bond, and bromide leaves.

Michael addition: a chain of arrows through a conjugated system

title: Michael addition
[CH2-:1]C(C)=O + [CH2:2]=[CH:3][C:4](C)=[O:5] ->[1,4-addition] CC(=O)CCC=C(C)[O-]
move :1 -> 1..2; 2-3 -> 3-4; 4-5 -> 5
Michael addition drawn from MolScript: an enolate carbon attacks the β-carbon and the electrons move through the C=C and C=O bonds onto oxygen
2-3 -> 3-4 moves the C=C π electrons into the C–C bond, making it a double bond.

Diels–Alder: arrows in a ring

title: Diels–Alder
[CH2:1]=[CH:2][CH:3]=[CH2:4] + [CH2:5]=[CH2:6] ->[Δ] C1CC=CCC1
move 1-2 -> 2-3; 3-4 -> 4..5; 5-6 -> 6..1
Diels–Alder reaction drawn from MolScript: three curly arrows around the cyclic transition state of butadiene and ethene giving cyclohexene
Two of the three arrows end on bonds being formed between the two molecules.

Radical addition: fish-hooks

title: Radical addition of Br• to propene
[Br:1] + [CH2:2]=[CH:3]C -> BrC[CH]C
move 1 ~> 1..2
move 2-3 ~> 1..2
move 2-3 ~> 3
Radical addition of a bromine atom to propene drawn from MolScript with three fish-hook arrows: two meet in the new C–Br bond and one goes to the carbon that becomes the radical
~> draws a fish-hook. The two that end on 1..2 meet in the middle of the new bond.

Resonance: an enolate

[CH2-:1][C:2](C)=[O:3] <-> C=C(C)[O-]
move :1 -> 1-2
move 2-3 -> 3
The two resonance forms of an enolate drawn from MolScript with a double-headed resonance arrow and two curly arrows
<-> is the resonance arrow; the curly arrows show how one form becomes the other.

Built on MolScript: whole figures

The mechanism figures in MolDraw's Templates panel (the button at the bottom of the left toolbar) are written in MolScript. Each step of Fischer esterification, the aldol addition and the Grignard addition is a short script; a template adds the panels, step labels, highlight circles and notes around them. Because the steps are text, every arrow in every figure is checked the same way as in the examples above.

Fischer esterification template: overall reaction with tracked oxygens, five-step curly-arrow mechanism, key points and a Dean–Stark apparatus
The Fischer esterification template: five MolScript steps inside a four-panel figure.

MolScript and chemfig

chemfig is the LaTeX package most chemists use to typeset structures and mechanisms. It is excellent at what it is for, and MolScript is not meant to replace it inside LaTeX. The two describe different things:

chemfigMolScript
You describeThe drawing: each bond's angle and length, then each arrow's anchor, offset and bend.The chemistry: species as SMILES and which electrons move where.
LayoutBy hand, per structure and per scheme.Automatic: structures, rows, conditions and captions.
Curly arrowsTikZ paths between named points; positions are fixed in a second LaTeX run.One move line between map numbers; placed and judged against drawing rules.
MistakesShow up as a wrong-looking PDF.Reported with line numbers: a missing map number, a start with no electrons, a bond that does not exist.
ResultTypeset output in a document.Editable canvas objects, plus image, vector and chemfig exports.
Best forFine typographic control inside a LaTeX document.Getting a correct, clean mechanism quickly, by hand or from an AI assistant.

They work together: draw with MolScript, then choose Download → chemfig (.tex) to get chemfig code for your document. The chemfig mechanism samples show what that code looks like.

Why text: MolScript and AI assistants

MolScript was designed so that a language model can draw a mechanism without ever handling coordinates:

  • Models already write SMILES well, so every species is in a notation they know.
  • Atom maps make arrows unambiguous. "From the lone pair on atom 1 to the bond forming between 1 and 2" cannot be misplaced the way "an arrow from the oxygen to the carbon" can.
  • Errors are actionable. A model that gets line 3: no atom is tagged :9 can fix line 3 and try again.
  • Geometry is not the model's job. Bends, gaps and clearances are decided and checked by the engine, which is where models are weakest.

The MolDraw AI chat already works this way: ask it for "the mechanism of the aldol addition" and it writes MolScript behind the scenes. We plan to publish MolScript as a packaged AI skill as well, a single bundle with the reference, the rules and worked examples, so any assistant that supports skills can write correct mechanisms.

Roadmap: from MolDraw feature to open framework

The plan is to release MolScript, its compiler and the scheme and arrow engine as an open-source framework that any canvas app can use to draw reactions and mechanisms, with the reliability of a programming language: a written specification, stable output and errors you can act on. This is what stands between today and that release.

The language

Species, operators, conditions, captions, continuation linesDone
Two-electron arrows and fish-hooks from lone pairs, charges, radicals and bondsDone
A versioned specification with a formal grammar and a conformance test setNext
Named species that can be reused: let A = …, then A in later stepsNext
Orientation hints: flip or turn a species, line up the reacting atoms across stepsNext
Transition states (‡, partial bonds), δ+ / δ−, brackets, highlights and step numbers in the scriptLater
Reagents drawn as structures above an arrow; abbreviations (Ph, Ts, Boc) and R groupsLater
Catalytic cycles with curly arrows, metal–ligand bonds and oxidation statesLater

Accuracy

Labels exist, starts have electrons, every drawn arrow passes the geometry rulesDone
Electron bookkeeping: work out the product the arrows imply and compare it with the product writtenNext
Charge and atom balance for each stepNext
Less ceremony: fewer explicit hydrogens and map numbers when the arrow is unambiguousLater

Layout

Rows packed by real widths; conditions and captions never overlapDone
Cleaner row breaks: turn the scheme back on the next row instead of one long elbow arrowNext
Explicit grid placement for figures with several schemesLater

The framework

Compiler and engine as a standalone package, independent of the MolDraw appNext
A stable, documented scheme format between the compiler and any rendererNext
Renderers for canvas and SVG; exporters for chemfig and other formatsNext
A command-line tool: a script in, an image or chemfig file outNext
Versioned layout, so a script draws the same way after an upgradeLater
Editor support: highlighting, inline errors, completion of map numbersLater
A public gallery of hundreds of reference mechanisms, each checked automaticallyLater

The AI skill

Used by the MolDraw AI chat, with line-numbered errors fed back to the modelDone
A packaged skill: reference, rules, worked examples and a check step an assistant can run before it answersNext
An evaluation set of mechanism prompts, scored for correct chemistry and clean arrowsNext

If you teach, write papers or build chemistry software and want to shape this, tell us through Request feature in MolDraw.

Try it

  1. Open MolDraw and the AI chat, and ask for a mechanism, for example "draw the E2 mechanism of 2-bromopropane with hydroxide". The chat writes the MolScript and draws it.
  2. Or open Templates at the bottom of the left toolbar and add the Fischer esterification, aldol or Grignard figure.
  3. Drag, restyle or extend the result like any drawing, then download it as an image or as chemfig.

Questions and answers

What is MolScript?

MolScript is a short text language for reaction schemes and curly-arrow mechanisms. Species are written as SMILES, joined by +, ->, <-> or <=>, and each curly arrow is one move line between atom-map numbers. MolDraw draws the structures, conditions, lone pairs, charges and arrows, and the result stays editable on the canvas.

How do I draw a curly arrow in MolScript?

Tag the atoms the arrow touches with atom-map numbers in the SMILES, for example [OH-:1] and [CH3:2][Br:3], then write move :1 -> 1..2 for the lone pair of atom 1 forming a bond to atom 2, and move 2-3 -> 3 for the C–Br bond breaking onto bromine.

How do I draw a fish-hook (one-electron) arrow?

Use ~> instead of ->: move 1-2 ~> 1 sends one electron of the bond between atoms 1 and 2 to atom 1. Two fish-hooks that end on the same forming bond (n..m) meet in the middle of it.

Is MolScript better than chemfig?

They solve different problems and work together. chemfig is a LaTeX package where you place every bond and arrow yourself inside a document. MolScript describes the chemistry and leaves layout and arrow geometry to MolDraw, which checks every arrow. Any MolScript drawing can be downloaded as chemfig code for a LaTeX document.

Can AI assistants write MolScript?

Yes. The MolDraw AI chat draws mechanisms by writing MolScript, because language models write SMILES well and atom maps make every arrow end unambiguous. Errors come back with line numbers so the model can fix them. A packaged AI skill is planned so other assistants can use it too.

Will MolScript be open source?

That is the plan: the language, the compiler and the scheme and arrow engine are to be released as an open framework that other canvas apps can use to draw reactions and mechanisms. The roadmap lists what has to be done first.

Related guides

Last updated: