COSMolKit Tools

Loading browser workspace

Back to tools

SMILES canonicalizer

Normalize SMILES serialization and inspect stereochemistry, aromatic bond form, hydrogens, and charge.

COSMolKit 0.2.12 / Rust / WASM

Normalized outputs

3 graph atoms / 6 total hydrogens
Canonical SMILES
CCO
Isomeric SMILES
CCO
Kekulized SMILES
CCO
H COUNT6
FORMAL CHARGE0
Canonicalized molecular structure
CANONICAL SMILES

Convert equivalent SMILES to a consistent representation

COSMolKit parses the molecular graph and writes canonical SMILES, stereochemistry-aware isomeric SMILES, and an explicit kekulized aromatic representation. Hydrogen count and total formal charge are derived from the same graph locally in WebAssembly.

PYTHON BACKEND

Canonicalize SMILES in Python

Use the COSMolKit Python bindings to generate the same canonical, isomeric, and kekulized outputs.

COSMolKit Python 0.2.12
canonicalize_smiles.py
from cosmolkit import Molecule

mol = Molecule.from_smiles("OCC")
result = {
    "canonical_smiles": mol.to_smiles(
        isomeric_smiles=False, canonical=True
    ),
    "isomeric_smiles": mol.to_smiles(
        isomeric_smiles=True, canonical=True
    ),
    "kekulized_smiles": mol.to_smiles(canonical=True, kekule=True),
    "hydrogen_count": sum(
        a.atomic_num() == 1 for a in mol.with_hydrogens().atoms()
    ),
    "formal_charge": sum(a.formal_charge() for a in mol.atoms()),
}
print(result)

COSMolKit Tools

Loading browser workspace