RDKit

2026.3.1 · active · verified Thu Apr 09

RDKit is a free, open-source toolkit for chemoinformatics, combining chemistry with computer science. It provides functionalities for analyzing molecules, predicting chemical properties, visualizing structures, and preparing data for drug discovery. The library is primarily written in C++ with extensive Python bindings. It maintains a regular release cadence with two major releases per year (typically March/April and September/October) and monthly patch releases, indicating active development and maintenance.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a molecule object from a SMILES string, retrieve basic properties like atom counts, and highlights the importance of adding explicit hydrogens for certain applications. It also shows how to visualize the molecule using `rdkit.Chem.Draw`.

from rdkit import Chem
from rdkit.Chem import Draw

# Create a molecule from a SMILES string
smiles_string = "CCO"
molecule = Chem.MolFromSmiles(smiles_string)

if molecule is not None:
    print(f"Successfully created molecule from SMILES: {smiles_string}")
    print(f"Number of heavy atoms: {molecule.GetNumHeavyAtoms()}")
    
    # Optionally add hydrogens for better geometry or calculations
    mol_with_hs = Chem.AddHs(molecule)
    print(f"Total number of atoms (including Hs): {mol_with_hs.GetNumAtoms()}")

    # Visualize the molecule (requires Pillow installed)
    # img = Draw.MolToImage(molecule)
    # img.show() # Uncomment to display image
else:
    print(f"Failed to create molecule from SMILES: {smiles_string}")
    print("This might happen for invalid SMILES strings or if sanitization fails.")

view raw JSON →