How to open a JCAMP-DX file (.jdx, .dx) online

JCAMP-DX is the open exchange format for spectra, maintained by IUPAC. Most spectroscopy software can export it: IR, Raman, UV-Vis, NMR and mass spectra. It is plain text, yet opening one in a spreadsheet rarely gives you usable numbers.

What is inside a JCAMP-DX file

The file starts with header lines of the form ##LABEL=value: the title, the data type (for example INFRARED SPECTRUM), the units of both axes, scale factors and the number of points. Then comes the data table. Files are usually saved as .jdx, .dx or .jcm.

The table is often compressed with letters instead of digits. The same three values can be written in several ways:

FormExample lineHow it works
AFFN4000 310 322 334Plain numbers. The first value on each line is the x position.
PAC4000+310+322+334Numbers separated by their signs instead of spaces.
SQZ4000C10C22C34The first digit becomes a letter (@ is 0, A to I are 1 to 9, a to i are −1 to −9), so no separators are needed.
DIF + DUP4000C10J2TAfter the first value, only the differences are stored (J2 is +12), and T repeats the last difference once more. This is the most compact form.

All four lines above decode to 310, 322 and 334. The real values are these numbers times the file's YFACTOR. A line that continues DIF data starts with a check value that repeats the last point; a reader must drop it, which is where many hand-written converters go wrong.

A .dx file can also be something else entirely: Agilent OpenLab CDS stores injections as zip archives with the same extension. Nagura Lab tells them apart by their contents, so both open.

In your browser

  1. Open Nagura Lab and drop one or more JCAMP-DX files on the page, or use Choose files.
  2. The spectrum is plotted with the axis it was recorded on: IR with high wavenumbers on the left, NMR in ppm, UV-Vis in nm. Mass spectra stored as peak tables are drawn as sticks.
  3. A file that holds several spectra lists each one separately. Spectra on the same axis can be overlaid.
  4. Download CSV gives the plotted spectra with a header such as Wavenumber (cm⁻¹); Download PNG gives the figure.

Every compression form above is supported. The file is decoded on your computer and never uploaded. If a file's data does not match the number of points it declares, it is refused with a message rather than shown with shifted values.

Not supported yet: multi-page files (##NTUPLES), used for NMR FIDs, complex NMR spectra and spectral series. They are listed with a clear message, and you can report them from the page.

In Python

The open-source jcamp package (MIT) reads spectra too:

import csv
import jcamp

d = jcamp.readfile("spectrum.jdx")
print(d["xunits"], d["yunits"], len(d["x"]))   # e.g. 1/CM TRANSMITTANCE 3951
with open("spectrum.csv", "w", newline="") as f:
    csv.writer(f).writerows(zip(d["x"], d["y"]))

Check the point count against the file's ##NPOINTS for compressed files: in our tests, Python and JavaScript readers disagreed with the file's own check values on some DIF/DUP files.