FoX: a Fortran XML library

Go straight to download


FoX, (Fortran XML) is a library, written entirely in Fortran, designed to allow the easy use of XML from Fortran programs.

Fortran and XML do not mix well. However, the vast majority of computational scientific codes in use, and under development, today, are written in Fortran, for a variety of reasons. It is desirable that much of the output from these codes be available marked up in XML for better data management.

There are a number of potential approaches to integrating Fortran codes into an XML-centric data world, including cross-language linking against existing XML libraries written in C; or having a separate post-processing stage which marks up unchanged text data from existing codes. However, with FoX, we have adopted the approach of writing the entire library in fully standard-compliant Fortran 95. This enables seamless use of FoX in any existing code, with no issues of cross-language compilation.

This has been a highly successful approach, and FoX is used in the currently released versions of the SIESTA DFT simulation code and DL_POLY molecular dynamics code. It will be in the next released version of GULP, and the next academic release of CASTEP.

FoX consists of an XML output library, which is allows the creation of XML documents containing the full ranges of constructs allowed by both the XML-1.0 & XML-1.1 specifications (selectable at runtime), as well as XML Namespaces 1.1. The output XML document is guaranteed to be well-formed according to the selected specification; attempts to create an ill-formed document will cause an error. (For precise details of the level of XML compliance, see the documentation.)

FoX also contains a wrapper library for outputting CML documents. This module allows developers unfamiliar with XML to easily arrange for CML output for their code, by abstracting away all details of the XML and resenting an intuitive interface with only common physical/chemical concepts.

In addition, as of version 2.1, FoX contains a SAX parser, fully compliant with SAX-2, supporting all callback events, and parsing the DTD in full. (Though note that currently FoX is a non-validating parser.



Release versions of FoX may be downloaded from

The currently released version is 2.1.1, which contains support for writing out generic XML, and CML; and a full SAX-2 compliant parser interface. Full documentation for FoX-2.1.1 is available at DoX/.


FoX is licensed under a 3-clause BSD license; which is to say that it may be used freely by any and all users; redistributed in source or binary form; provided always that the copyright notices are maintained. This is the full license text.

Mailing list

There is a mailing list for FoX users, where announcements of bug-fixes, new releases, and general help/discussion may be directed. Subscription information can be found at


FoX is under continuing development. The development process is open, and patches for bug-fixes or further features are encouraged. The source code is kept within the git revision control system. The primary source code repository is available at, and may be browsed online.