Markdown chemical structure drawer

Draw a molecule from its SMILES string. Type the formula and get a clean chemical structure to embed in notes or teaching material.

The editor format

The editor writes one small text block, fenced as ```smiles. The first line is the keyword chemistry. Every line after that is one molecule: a SMILES string, then an optional label in double quotes. Lines starting with # are comments.

You write
chemistry
c1ccccc1 "Benzene"
CC(=O)O "Acetic acid"
CCO "Ethanol"
You get
Line Meaning
chemistryThe first line — names the format
c1ccccc1A molecule, drawn from its SMILES string
CCO "Ethanol"A molecule with a caption in double quotes
# noteA comment, ignored when drawing

A SMILES primer

SMILES writes a molecule as a short string of atoms. Letters are atoms, atoms next to each other are bonded, and hydrogens are filled in for you. Here is each piece you can write.

Atoms and bonds

Write element symbols in a row. Neighbouring atoms are joined by a single bond.

You write
CCO
You get

Double and triple bonds

Put = for a double bond or # for a triple bond between atoms.

You write
CC(=O)O
You get

Branches

Open a branch with a round bracket and close it to return to the main chain.

You write
CC(C)CO
You get

Rings

Match a pair of digits to close a ring, or use lowercase letters for an aromatic ring.

You write
c1ccccc1
You get

Cheat sheet

Write this You get
CA carbon atom, with hydrogens added for you
O N SOther atoms by element symbol
CCA single bond between neighbours
=A double bond
#A triple bond
( )A branch off the main chain
1 ... 1Matching digits close a ring
c1ccccc1Lowercase letters make an aromatic ring

Common molecules

Handy SMILES snippets to paste into the SMILES box.

Molecule SMILES
WaterO
EthanolCCO
Acetic acidCC(=O)O
Benzenec1ccccc1
PhenolOc1ccccc1
AspirinCC(=O)Oc1ccccc1C(=O)O
CaffeineCn1cnc2c1c(=O)n(C)c(=O)n2C
GlucoseOCC1OC(O)C(O)C(O)C1O