Convert SDF to SVG using Open Babel


How to convert Convert SDF to SVG (Scalable Vector Graphics) using Open Babel? I want to see the molecule structure as a SVG file.

✍: Guest


If you want to see the molecule structure specified in a SDF file, you can convert it to a SVG (Scalable Vector Graphics) file using the "Open Babel" tool.

1. Download and install "Open Babel" 2.3.1 from

2. Run the following "babel" command to convert SDF to SVG:

fyicenter$ babel Molecule-FYI-001.sdf Molecule-FYI-001.svg
  1 molecule converted
  29 audit log messages

3. Open the SVG file, Molecule-FYI-001.svg, in a text editor to review:

<?xml version="1.0"?>
<svg xmlns=""
  width="149.961" height="333.147" x="0" y="0"
  font-family="sans-serif" font-size="16"
  stroke="rgb(0,0,0)" stroke-width="1"  stroke-linecap="round">
<rect x="0%" y="0%" width="100%" height="100%" stroke-width="0"
 fill="rgb(255,255,255)"  />
<line x1="75.4" y1="213.5" x2="75.4" y2="186.5"/>
<line x1="107.2" y1="74.5" x2="87.9" y2="110.4"/>
<line x1="92.8" y1="51.1" x2="107.2" y2="74.5"/>
<line x1="85.0" y1="164.7" x2="95.3" y2="155.1"/>
<line x1="99.3" y1="134.5" x2="87.9" y2="110.4"/>
<line x1="91.9" y1="135.7" x2="83.9" y2="118.9"/>
<line x1="87.9" y1="110.4" x2="49.2" y2="114.6"/>
<line x1="49.2" y1="114.6" x2="43.7" y2="140.8"/>
<line x1="55.0" y1="121.9" x2="51.1" y2="140.3"/>
<line x1="52.2" y1="160.2" x2="64.2" y2="167.0"/>
<line x1="75.4" y1="213.5" x2="110.0" y2="233.3"/>
<line x1="110.0" y1="233.3" x2="110.0" y2="273.4"/>
<line x1="102.8" y1="239.3" x2="102.8" y2="267.4"/>
<line x1="110.0" y1="273.4" x2="75.4" y2="293.1"/>
<line x1="75.4" y1="293.1" x2="40.0" y2="272.9"/>
<line x1="73.8" y1="283.9" x2="48.8" y2="269.6"/>
<line x1="40.0" y1="272.9" x2="40.5" y2="233.3"/>
<line x1="40.5" y1="233.3" x2="75.4" y2="213.5"/>
<line x1="49.2" y1="236.6" x2="73.8" y2="222.7"/>
<text x="69.440616" y="181.477643" stroke="rgb(12,12,255)">N</text>
<text x="98.897751" y="154.321847" stroke="rgb(12,12,255)">N</text>
<text x="34.920535" y="161.686130" stroke="rgb(12,12,255)">N</text>
<text x="68.026773" y="48.000000" stroke="rgb(30,239,30)">Cl</text>
<text font-size="18.000000" fill ="black" font-family="sans-serif"
  x="10.000000" y="20.000000" >FYI-001</text>
<title>FYI-001 - OBDepict</title>

4. Open the SVG file, Molecule-FYI-001.svg, in a Web browser. You see the molecule structure:

Open Babel - Convert SDF to SVG
Open Babel - Convert SDF to SVG


sdf2svg - PHP Script to Convert SDF to SVG

What Are CTfile and CTAB

Introduction to SDF/Mol File Format

⇑⇑ SDF/Mol File FAQ

2020-04-16, 199👍, 0💬