MDL CTFile to X3D Converter
Convert MDL CTFile MOL and SDF chemical structure files to X3D 3D format online. Parse V2000 molfiles and generate X3D with CPK coloring and bonds.
About
MDL CTFile (Connection Table File) is the de facto interchange format for 2D and 3D chemical structures, codified by Accelrys (now Dassault Systèmes) in the V2000 and V3000 specifications. The atom block encodes Cartesian coordinates (x, y, z) with element symbols, formal charges, and mass differences, while the bond block encodes connectivity with bond order (1 - 3) and stereo flags. Misinterpreting fixed-width column offsets or ignoring implicit hydrogen counts produces incorrect topology, which cascades into wrong 3D geometry, broken atom-atom mapping, and invalid reaction animations. This tool parses V2000 MOL and SDF files column-by-column per the Accelrys specification, validates atom/bond counts against the counts line, and generates well-formed X3D XML with CPK-colored Sphere nodes for atoms and oriented Cylinder nodes for bonds. The tool approximates bond geometry assuming rigid-body placement; it does not perform energy minimization or conformer optimization.
Formulas
The V2000 counts line occupies line 4 of a MOL file (0-indexed line 3). Atom count is extracted from columns 0 - 2 and bond count from columns 3 - 5 (right-justified, 3-character fields). Each atom line provides Cartesian coordinates in Ångströms:
For X3D bond cylinders, the converter computes the midpoint, length, and rotation between two atom positions A and B:
The rotation axis is the cross product of the Y-axis unit vector j = (0, 1, 0) and the bond direction unit vector d:
Where L is the Euclidean bond length in Ångströms, θ is the rotation angle in radians, and axis is the normalized rotation vector for the X3D rotation attribute formatted as "ax ay az angle".
Reference Data
| Element | Symbol | CPK Color | Hex | Van der Waals Radius (Å) | Sphere Scale Factor | Atomic Number |
|---|---|---|---|---|---|---|
| Hydrogen | H | White | #FFFFFF | 1.20 | 0.25 | 1 |
| Carbon | C | Dark Grey | #555555 | 1.70 | 0.40 | 6 |
| Nitrogen | N | Blue | #3050F8 | 1.55 | 0.38 | 7 |
| Oxygen | O | Red | #FF0D0D | 1.52 | 0.37 | 8 |
| Fluorine | F | Green | #90E050 | 1.47 | 0.35 | 9 |
| Phosphorus | P | Orange | #FF8000 | 1.80 | 0.42 | 15 |
| Sulfur | S | Yellow | #FFFF30 | 1.80 | 0.42 | 16 |
| Chlorine | Cl | Green | #1FF01F | 1.75 | 0.41 | 17 |
| Bromine | Br | Dark Red | #A62929 | 1.85 | 0.43 | 35 |
| Iodine | I | Violet | #940094 | 1.98 | 0.45 | 53 |
| Iron | Fe | Orange | #E06633 | 2.00 | 0.46 | 26 |
| Calcium | Ca | Dark Green | #3DFF00 | 2.31 | 0.50 | 20 |
| Sodium | Na | Purple | #AB5CF2 | 2.27 | 0.49 | 11 |
| Magnesium | Mg | Green | #8AFF00 | 1.73 | 0.41 | 12 |
| Zinc | Zn | Slate | #7D80B0 | 1.39 | 0.35 | 30 |
| Copper | Cu | Salmon | #C88033 | 1.40 | 0.35 | 29 |
| Silicon | Si | Gold | #F0C8A0 | 2.10 | 0.47 | 14 |
| Boron | B | Salmon | #FFB5B5 | 1.92 | 0.44 | 5 |
| Unknown | * | Pink | #FF1493 | 1.50 | 0.36 | - |