a freeware tool for 2D depiction of molecular structures

mol2ps is a freely available command-line utility program which reads molecular structure files in different formats (see below) and generates Postscript output for 2D display. The Postscript file can then be used e.g. for creating a bitmap file, using a Postscript interpreter like Ghostscript.

As an example, the following 2D representation of caffeine in PNG (Portable Network Graphics) format was created from the corresponding MDL molfile (PubChem CID 2519), using mol2ps in combination with Ghostscript:

Caffeine 2D structure

As input files, MDL molfiles and SD files (*.mol, *.sdf; 2D and 3D), Alchemy molfiles (*.mol), and Sybyl mol2 files (*.mol2) are accepted by mol2ps, the preferred format is the MDL molfile format. At present, it is not intended to extend the number of supported input file formats, as there are powerful file format converters available, such as OpenBabel. Starting with mol2ps version 0.2, also reactions are supported in MDL reactionfile (*.rxn) and RD file (*.rdf) format. An example is shown below.


The main purpose of mol2ps is to create small, but high-quality 2D pictures of molecules for display on web pages. Especially for web-based molecular structure databases it is quite useful to have pre-built pictures for display in hitlists instead of invoking browser plugins, Java applets, or server-side programs for display of the individual structures. A description of how such structure databases can be created with free software is given here.

mol2svg is actually the same program as mol2ps (starting from version 0.3), so there is only one source code. Depending on its name (mol2ps or mol2svg), the program generates either PostScript or SVG (scalable vector graphics) output. This means you just have to rename (or copy or hard-link) the mol2ps executable into mol2svg in order to get this functionality.


mol2ps is freely available under the terms of the GNU General Public License (GPL), for a detailed description of this license, please visit
It is written in Pascal and it was compiled with the Free Pascal compiler for the following platforms: Linux (x86), FreeBSD (x86), Mac OS X (x86)  and Windows (Win32 console application). You may use it on your own risk, there is no warranty for anything.


source code: mol2ps.pas 
Linux (i386) executable: mol2ps-latest-linux-i386.gz 
FreeBSD (i386) executable: mol2ps-latest-freebsd-i386.gz 
Mac OS X (x86) executable: mol2ps-latest-macosx-x86.gz 
Win32 console application: 
example color definition file: color.conf


Download the appropriate compressed binary file for your system, uncompress it and rename the resulting executable file into mol2ps (for Linux, Mac OS X, or FreeBSD), for Windows there is no need to rename the extracted file, mol2ps.exe. Copy this program file into a directory which is in your search path (e.g., /usr/local/bin or C:\UTIL). There are no additional files or libraries required. For mol2svg, copy or rename/hard-link the mol2ps executable into mol2svg (Windows: mol2svg.exe).

Usage (command-line options)

mol2ps can be invoked with the following arguments (version 0.4)
mol2ps [options] <filename>
where <filename> is the file containing the molecular structure
 (supported formats: MDL *.mol or *.sdf, Alchemy *.mol, Sybyl *.mol2)
 if <filename> is "-" (without quotes), the program reads from standard input
valid options are:
  -R (reaction mode, for MDL rxn and rdf files)
  --font=<Helvetica|Times>, default: Helvetica
  --fontsize=<any number in points>, default: 14
  --fontsizesmall=<any number in points>, default: 9 (for subscripts)
  --linewidth=<n.n>, default: 1.0 (linewidth in points; use 1 decimal)
  --rotate=<auto|auto3Donly|n,n,n>, default: auto (n,n,n specifies the
    angles to rotate the molecule around the X, Y, and Z axis (in degrees)
  --autoscale=<on|off>, default: on (scales the molecule to fit the natural
    C-C bond length)
  --striphydrogen=<on|off>, default: on (strips all explicit H atoms)
  --hydrogenonhetero=<on|off>, default: on (adds H to all hetero atoms)
  --hydrogenonmethyl=<on|off>, default: on (adds H to all methyl C atoms)
  --hydrogenonstereo=<on|off>, default: on (shows H if bond is "up" or "down")
  --showmolname=<on|off>, default: off (prints name above the structure)
  --atomnumbers=<on|off>, default: off (prints atom numbers)
  --bondnumbers=<on|off>, default: off (prints bond numbers)
  --sgroups=<on|off>, default: on (uses Sgroup abbreviations if present)
  --showmaps=<on|off>, default: off (prints atom-atom mapping numbers)
  --color=</path/to/color.conf>, default: no colors for atoms labels
  --bgcolor=<white|gray|n,n,n> where n,n,n are the RGB values (0-255)
  --scaling=<n.n>, default: 1.0 (any scaling factor from 0.1 to 10.0)
  --output=<ps|eps|svg>, default depends on prog name (mol2ps, mol2eps, mol2svg)

Postscript (PS, EPS) or SVG output will be written to standard output. To write it to a file, enter something like the following:
mol2ps mymolecule.mol >


The program attempts by default to orient the molecule in a suitable way if it contains a ring structure. Especially with 3D molfiles, this is quite useful, but sometimes can give unsatisfactory results. Please inspect the generated Postscript file with a text editor: in the file header, the applied angles of rotation around the X, Y, and Z axis are noted as Postscript comments (lines starting with a % sign). You can take these values as starting points for some manual optimization, using the command-line argument "--rotate=" (see above), for example --rotate=10,-23,75 (which would rotate the structure by 10° around X, -23° around Y, and 75° around Z).

Useful Perl scripts for batch processing

If you want to convert an MDL molfile or an entire SD file directly into 2D bitmap pictures in PNG format, take a look at the Perl script For conversion of an already existing Postscript file into a PNG image file, the script is available. These scripts use Ghostscript not only for rastering, but also to determine suitable dimensions of the output bitmap file (using the "bbox" device of Ghostscript). Of course, the resulting PNG bitmap files can be converted into any other bitmap format (such as GIF) by almost any graphics conversion utility program.
In SVG mode, the actual height, width and viewbox dimensions can be adjusted. The program writes a few comment lines after each </svg> closing tag which contain the values necessary for this re-adjustment of the header line. For this purpose, a Perl script ( is provided in the download directory.

was written by Norbert Haider, Department of Drug and Natural Product Synthesis, University of Vienna, Austria. You can contact me by e-mail: (no spam, no viruses, no HTML mails, please).

N. Haider, 2005-09-21; last update: 2013-05-29