Skip to main content
v2026.11,986 entries · CC-BY 4.0

Open Babel (obabel): Convert Chemical Files and Run Workflows

Open Babel (obabel) worked guide: install by OS, SMILES to 3D SDF, SMARTS filtering, descriptors, pybel and common pitfalls.

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.

  1. Check formats. obabel -L formats lists supported formats; obabel -L descriptors lists descriptor IDs usable later. obabel -H prints help.
  2. 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.
  3. Select by substructure. obabel mymols.sdf -O selected.sdf -s "c1ccccc1Br" keeps molecules matching the SMARTS pattern; add -v to invert the selection.
  4. Take a range. obabel mymols.sdf -f 2 -l 4 -osdf -O outputfile.sdf writes molecules 2 to 4 (-f first, -l last).
  5. 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.
  6. Split or compress. obabel infile.mol -O new.smi -m writes one file per molecule; obabel *.xyz -opdb -m converts a batch. obabel mymols.sdf -O outputfile.sdf.gz -z gzips the output (the .gz suffix is not added for you), and gzipped input is read transparently.
  7. Keep going past bad records. Add -e to 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 --append parameter is punctuation other than an underscore it becomes the separator, and a leading “t” selects a tab.
  • --addinindex adds the input index (before filtering) and --addoutindex the 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

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Open Babel (obabel): Convert Chemical Files and Run Workflows

2 free questions a day, no account.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →