Written and maintained by CASRAI Editorial Board
Published
On this page
Open Babel is an open-source chemistry toolbox. Its command-line program, obabel, converts between the many file formats used in molecular modeling and computational chemistry, and its Python bindings (pybel) expose the same engine to scripts. This guide is for researchers who need to convert, filter and annotate molecule files reproducibly. It is not an R or CRAN/Bioconductor package. Documentation read 2026-11-12.
What Open Babel is used for in research
The Open Babel documentation describes obabel as a “command-line program for interconverting between many file formats used in molecular modeling and computational chemistry”. The software is described in O’Boyle et al., “Open Babel: An open chemical toolbox”, Journal of Cheminformatics 2011, 3:33 (PubMed 21982300); cite it in methods sections. The project’s source repository carries the GNU General Public License, version 2 (checked in the repository’s COPYING file, 2026-11-12).
Typical uses are format conversion (for example SMILES to SDF or XYZ to PDB), batch splitting of multi-molecule files, substructure filtering with SMARTS, hydrogen handling, 2D/3D coordinate generation and descriptor calculation. For where this tooling sits in the field, see the bioinformatics vs cheminformatics comparison.
Install or access
Use the official project sources: openbabel.org, the installation page and the GitHub releases. The latest GitHub release tag at the time of checking (2026-11-12) was openbabel-3-2-1.
| Platform | Route the documentation describes |
|---|---|
| Windows | Installer from the GitHub releases page (64-bit preferred). For Python, install the matching Open Babel first (32-bit and 64-bit must match your Python), then pip install -U openbabel. Optionally pip install -U pillow for 2D display. |
| Linux | Binary packages from distributions including Ubuntu, OpenSUSE and Fedora, or build from source. |
| Build from source | Needs a C++ compiler and CMake: mkdir build, cd build, cmake ../openbabel-X, make, sudo make install. |
| Python bindings from source | Configure with -DPYTHON_BINDINGS=ON (requires Eigen); regenerating the SWIG wrappers uses -DRUN_SWIG=ON. |
The Python install page gives a pip command only for Windows; on Linux and macOS it directs you to compile the language bindings with CMake. If the program cannot find plugins or data at run time, the installation notes point to the environment variables BABEL_LIBDIR, BABEL_DATADIR and LD_LIBRARY_PATH. Confirm the install with obabel -V.
Step-by-step: from a SMILES library to a filtered, annotated 3D SDF
This worked workflow chains documented options; every flag below appears in the obabel documentation. Run each step on a small test file first.
- Check formats.
obabel -L formatslists supported formats;obabel -L descriptorslists descriptor IDs usable later.obabel -Hprints help. - Convert and generate 3D coordinates.
obabel infile.smi -O out.sdf --gen3d. The documentation states Open Babel will not generate coordinates unless asked, so a SMILES-to-SDF conversion without--gen3d(or--gen2d) yields no real geometry. - Select by substructure.
obabel mymols.sdf -O selected.sdf -s "c1ccccc1Br"keeps molecules matching the SMARTS pattern; add-vto invert the selection. - Take a range.
obabel mymols.sdf -f 2 -l 4 -osdf -O outputfile.sdfwrites molecules 2 to 4 (-ffirst,-llast). - Annotate with descriptors.
obabel infile.sdf -osmi --append "MW CAT_NO"appends the molecular-weight descriptor (MW) and an SDF property (CAT_NO) to each molecule title. Put all IDs inside one set of quotes; spaces in SDF property names become underscores. - Split or compress.
obabel infile.mol -O new.smi -mwrites one file per molecule;obabel *.xyz -opdb -mconverts a batch.obabel mymols.sdf -O outputfile.sdf.gz -zgzips the output (the .gz suffix is not added for you), and gzipped input is read transparently. - Keep going past bad records. Add
-eto continue after errors in a large file.
If you give only file names, the format is guessed from the extension (obabel ethanol.xyz -O ethanol.pdb); use -i/-o with format IDs when the extension is unreliable (obabel -ixyz ethanol.aa -opdb -O ethanol.bb). With obabel -:"<text>" the text is read as SMILES by default.
The same task in Python (pybel)
Import with from openbabel import pybel. The Pybel documentation shows pybel.readstring("smi","CCCC") for a string, pybel.readfile("sdf","file.sdf") for files (a generator; use next() for a single molecule), mol.make3D() for coordinates, mol.calcdesc() (or mol.calcdesc(["LogP","TPSA"])) for descriptors, and mol.write("smi") to return a string or mol.write("smi","out.txt") to write a file (pass overwrite=True to replace one). pybel.Outputfile("sdf","multi.sdf") writes many molecules. Fingerprints: mol.calcfp() defaults to FP2, and the Tanimoto similarity of two fingerprints is fp1 | fp2. The lower-level interface is from openbabel import openbabel with OBConversion().SetInAndOutFormats("smi","mdl"), ReadString and WriteString.
Output and how to read it
- Appended values appear in the molecule title, separated by spaces by default; if the first character of the
--appendparameter is punctuation other than an underscore it becomes the separator, and a leading “t” selects a tab. --addinindexadds the input index (before filtering) and--addoutindexthe output index (after filtering) to the title, which lets you trace a filtered record back to its original position.- Descriptor IDs come from
obabel -L descriptors; report the descriptor ID and Open Babel version in your methods.
Troubleshooting and pitfalls
| Symptom | What the documentation says |
|---|---|
| Output has no 3D geometry | Coordinates are generated only when requested with --gen3d or --gen2d. |
| Conversion stops on a bad record | Use -e to continue after errors. |
| Hydrogens at physiological pH | -p adds hydrogens appropriate for pH 7.4, applied atom by atom; -h adds hydrogens and -d deletes them. |
| Compressed output has the wrong name | With -z the .gz suffix is not added automatically; name the file .sdf.gz yourself. |
| Python on Windows cannot load the library | The 32/64-bit build of Open Babel must match your Python. |
| Plugins or data not found | Set BABEL_LIBDIR, BABEL_DATADIR and LD_LIBRARY_PATH. |
Free alternatives
| Tool | Relationship |
|---|---|
| RDKit | Open-source cheminformatics toolkit with Python bindings; CASRAI also has an RDKit guide. |
| SwissADME | Web tool for property and drug-likeness estimation, a different job from file conversion. |
| UniChem | Identifier cross-referencing service across chemistry databases. |
FAQ
What is Open Babel?
An open-source chemistry toolbox with a command-line converter (obabel) and bindings including Python, used to convert and process molecular file formats (O’Boyle et al., 2011).
Is Open Babel an R package?
No. It is a C++ toolkit with a command-line program and language bindings such as Python’s pybel.
Which license does Open Babel use?
The repository’s COPYING file is the GNU GPL version 2 (checked 2026-11-12).
How do I cite it?
O’Boyle NM, Banck M, James CA, Morley C, Vandermeersch T, Hutchison GR. Open Babel: An open chemical toolbox. J Cheminform. 2011;3:33.
Sources
- Open Babel: obabel command-line documentation (read 2026-11-12)
- Open Babel: installation (read 2026-11-12)
- Open Babel: Python installation (read 2026-11-12)
- Open Babel: Pybel (read 2026-11-12)
- O’Boyle et al. 2011, J Cheminform 3:33
- Open Babel on GitHub (releases and COPYING, read 2026-11-12)







