Blog
How to Convert Molecular File Formats with Open Babel (PDB to PDBQT, MOL2 and SDF): A Beginner’s Guide
- July 25, 2026
- Posted by: Stem Skills Lab
- Category: Molecular Modeling

To convert a PDB to PDBQT for AutoDock Vina, install Open Babel and run obabel receptor.pdb -O receptor.pdbqt -xr for a rigid receptor, or obabel ligand.pdb -O ligand.pdbqt -p 7.4 for a ligand. The same tool interconverts PDB, PDBQT, MOL2, SDF and SMILES from a single command, adds hydrogens, and generates 3D coordinates, so your structure is docking-ready in minutes.
Almost every docking and molecular dynamics beginner hits the same wall on day one. You download a protein from the RCSB Protein Data Bank as a .pdb file. AutoDock Vina refuses to read it and demands .pdbqt. A force-field parameteriser wants .mol2 or .sdf. Your ligand came as a SMILES string with no 3D shape at all. One free tool clears all of it: Open Babel. This guide from the StemSkills Lab team, drawing on more than a decade in structural bioinformatics and drug design, shows you the exact commands that matter and how to fix the conversions that silently break.
What is Open Babel and why do you need it for docking?
Open Babel is a free, open-source chemistry toolbox that reads and writes chemical file formats and converts between them. Its developers describe it as “a chemical toolbox designed to speak the many languages of chemical data” (O’Boyle et al., 2011). The tool supports more than 110 chemical file formats, which is why it has become the default translator in computational chemistry pipelines (O’Boyle et al., Journal of Cheminformatics, 2011).
You need it because docking and simulation engines each speak a different dialect. AutoDock Vina reads only PDBQT, a PDB variant that stores partial charges (the Q) and AutoDock atom types (the T), as set out in the original Vina paper (Trott and Olson, 2010). GROMACS ligand parameterisation tools expect MOL2 or SDF because those formats record bond orders and charges that a plain PDB does not. Open Babel sits between them and converts on demand.
How do you install Open Babel?
The most reliable route for students is Conda, because it pulls a pre-built binary with no compilation:
- Conda (Windows, macOS, Linux):
conda install -c conda-forge openbabel - Ubuntu / Debian:
sudo apt-get install openbabel - Graphical version: install the cross-platform Open Babel GUI, which wraps the same engine in a point-and-click window if you prefer not to use a terminal.
Confirm the install and check your version with obabel -V. The current stable release is Open Babel 3.1.1. Every command below uses the obabel executable; older tutorials that call babel refer to the legacy 2.x interface, so prefer obabel.
How do you convert a PDB to PDBQT for AutoDock Vina?
This is the conversion most people arrive for. Treat the receptor and the ligand differently.
Receptor (kept rigid):
obabel receptor.pdb -O receptor.pdbqt -xr
The -xr output option writes a rigid receptor with no rotatable bonds, which is what Vina expects for the target. Strip waters and any bound ligand from the PDB first, and make sure the structure has hydrogens.
Ligand (with rotatable bonds and charges):
obabel ligand.pdb -O ligand.pdbqt -p 7.4
The -p 7.4 flag adds hydrogens for a physiological pH of 7.4. When Open Babel writes a PDBQT ligand it computes Gasteiger partial charges and detects the rotatable-bond torsion tree automatically. If you want the charge model to be explicit, add it: obabel ligand.mol2 -O ligand.pdbqt --partialcharge gasteiger.
One honest caveat: for the receptor, many published protocols still prefer AutoDockTools (prepare_receptor4.py) because it handles chain breaks and alternate conformations more carefully. Open Babel is excellent for ligands and for fast batch conversion, and it is more than enough to get a beginner docking correctly.
Want the guided, hands-on version?
Our live Molecular Modeling & MD Simulations cohort bootcamp takes you from zero to running real docking and MD workflows, with a portfolio project for your grad-school applications.
How do you convert between MOL2, SDF, PDB and SMILES?
Every conversion follows the same pattern: obabel INPUT -O OUTPUT. Open Babel picks the format from the file extension. A few you will use constantly:
- PDB to MOL2:
obabel ligand.pdb -O ligand.mol2 - PDB to SDF:
obabel ligand.pdb -O ligand.sdf - PDB to SMILES:
obabel ligand.pdb -O ligand.smi - SMILES string straight to a file:
obabel -:"CC(=O)Oc1ccccc1C(=O)O" -O aspirin.sdf --gen3d - MOL2 to PDBQT:
obabel ligand.mol2 -O ligand.pdbqt
The -: prefix lets you pass a SMILES string directly on the command line instead of a file, which is handy when you are pulling structures from a database such as PubChem or ChEMBL.
Which molecular file format stores what?
Conversions break when a format cannot hold the information the next tool needs. This table shows what each format carries so you can predict when data will be lost.
| Format | 3D coordinates | Bond orders | Partial charges | Best used for |
|---|---|---|---|---|
| PDB | Yes | No (CONECT optional) | No | Downloading proteins from the RCSB PDB |
| PDBQT | Yes | No (torsion tree) | Yes (Gasteiger) | Input for AutoDock Vina and AutoDock4 |
| MOL2 | Yes | Yes | Yes (Tripos/Gasteiger) | Ligand parameterisation, force-field setup |
| SDF | Yes (if 3D) | Yes | Optional (property block) | Compound libraries, virtual screening |
| SMILES | No | Yes (implicit) | No | Storing 2D identity, database queries |
The pattern to remember: a plain PDB has no bond orders or charges, and SMILES has no 3D shape. Any time you go from one of those to a docking or simulation format, you must rebuild the missing information, which is what the next section covers.
When should you add hydrogens and 3D coordinates?
Two situations force an extra step.
Missing hydrogens. Crystallographic PDB files rarely include hydrogen atoms, yet docking and force fields need them. Add them one of two ways:
obabel in.pdb -O out.pdb -hadds all hydrogens.obabel in.pdb -O out.pdb -p 7.4adds hydrogens for a target pH, so acidic and basic groups get the correct protonation state. Use-pfor anything you will dock or simulate.
Missing 3D coordinates. A SMILES or 2D structure has no geometry. Generate a 3D conformer with --gen3d:
obabel -:"CCO" -O ethanol.sdf --gen3d
Without --gen3d, converting a SMILES to SDF gives you a flat molecule with all atoms at coordinate zero, and docking will fail or return nonsense. Generating 3D coordinates once, then converting to PDBQT, is the correct order.
How do you split or join multi-molecule files?
Screening libraries arrive as one SDF holding thousands of compounds. Open Babel splits and merges them.
- Split one file into many:
obabel library.sdf -O ligand.sdf -mwritesligand1.sdf,ligand2.sdfand so on. The-mflag means “produce multiple output files”. - Join many files into one:
obabel lig1.mol2 lig2.mol2 lig3.mol2 -O combined.sdfconcatenates them into a single multi-molecule SDF. - Convert and split in one pass:
obabel library.sdf -O ligand.pdbqt -mgives you a separate PDBQT per compound, ready for batch docking.
Troubleshooting: the Open Babel errors that stop beginners
These are the failures that actually cost students an afternoon, with the fix for each.
- “Failed to kekulize aromatic bonds” or valence warnings. The input PDB has no bond-order information, so Open Babel guesses and sometimes gets aromatic rings wrong. Convert from a format that carries bond orders (MOL2 or SDF) where possible, or download the ligand as SDF rather than PDB.
- Empty or suspiciously short PDBQT. Usually the input had no hydrogens, so the torsion tree could not be built. Re-run with
-p 7.4to add hydrogens before writing the PDBQT. - Charges are all zero. A PDB carries no charges, so a straight PDB-to-PDBQT can lose them. Force the charge model with
--partialcharge gasteiger, or route through MOL2 first. - Wrong protonation state. Using bare
-hignores pH. For biological targets use-p 7.4so histidines, carboxylates and amines are protonated realistically. - Flat molecule after SMILES conversion. You forgot
--gen3d. Add it so the molecule gets real 3D coordinates before docking.
When a conversion looks wrong, open the output in a viewer such as PyMOL or the Open Babel GUI before you dock. A ten-second visual check catches missing hydrogens and broken rings that no error message will warn you about.
Once your receptor and ligand are clean PDBQT files, you are ready for the docking run itself. Work through the full path in our molecular docking learning hub, and see where structure preparation sits in the wider pipeline on the computational biology skills roadmap.
Frequently asked questions
Is Open Babel free to use?
Yes. Open Babel is open-source software released under the GNU GPL, free for academic and commercial use, and it runs on Windows, macOS and Linux.
What is the difference between PDB and PDBQT?
PDBQT is a PDB extended with partial charges (Q) and AutoDock atom types (T), plus a torsion tree that defines rotatable bonds. AutoDock Vina and AutoDock4 read PDBQT; they cannot use a plain PDB.
Do I need AutoDockTools if I have Open Babel?
Not for ligands, where Open Babel is fully sufficient and faster for batches. For receptors, AutoDockTools (prepare_receptor4.py) is often preferred because it handles chain breaks and alternate locations more carefully, but Open Babel with -xr works well for straightforward targets.
Why is my converted molecule flat or missing atoms?
A flat molecule means you converted from SMILES or 2D without --gen3d; add that flag. Missing atoms usually means missing hydrogens; add them with -p 7.4 before converting.
Can Open Babel add hydrogens at a specific pH?
Yes. Use -p followed by the pH, for example -p 7.4, and Open Babel assigns protonation states appropriate to that pH rather than simply saturating every atom.
Want the guided, hands-on version?
Our live Molecular Modeling & MD Simulations cohort bootcamp takes you from zero to running real docking and MD workflows, with a portfolio project for your grad-school applications.
Written by the StemSkills Lab team, computational scientists with more than 10 years of combined experience in sequence and structural bioinformatics, drug discovery and multiscale molecular modeling.