The NEXUS format, explained
NEXUS is a container format for phylogenetics. Where a Newick file is a single line, a NEXUS file wraps one or more trees together with the taxon list and other data, all sorted into labelled blocks. Files usually end in .nex or .nexus.
What NEXUS is
NEXUS was designed in the 1990s as a single format flexible enough to carry everything a phylogenetics program needs: the list of taxa, a character or sequence matrix, one or more trees, and settings for the analysis. Instead of a bare tree, you get a small structured document. That is why programs like MrBayes and PAUP* read and write it: a NEXUS file can hold the whole project, not just the result.
The trade-off is that NEXUS is wordier than Newick. For simply passing one tree from A to B, Newick is lighter. For carrying data, trees and settings together, NEXUS is the format built for the job.
The shape of a NEXUS file
Every NEXUS file starts with the line #NEXUS. After that it is a series of blocks, each opening with BEGIN name; and closing with END;. The common ones are:
- TAXA, the list of taxon names and how many there are.
- DATA or CHARACTERS, the character matrix or aligned sequences.
- TREES, one or more trees, each written as a Newick string.
A worked example
Here is a small but complete NEXUS file: four primates, and one tree relating them.
#NEXUS
BEGIN TAXA;
DIMENSIONS NTAX=4;
TAXLABELS Human Chimp Gorilla Orangutan;
END;
BEGIN TREES;
TREE primates = (((Human,Chimp),Gorilla),Orangutan);
END;Read the TREES block and you will recognise plain Newick inside it. Everything else is scaffolding: the header declares the format, the TAXA block names the four taxa, and DIMENSIONS NTAX=4 states how many to expect. A reader can check the tree against the declared taxon list.
The TREES block is Newick inside
This is the key thing to hold on to: a NEXUS tree is a Newick tree with a wrapper around it. The parentheses, the commas, the colons for branch lengths and the numbers for support values all follow the same rules as a standalone Newick file. If you can read one, you can read the other. The Newick format guide covers that syntax in full.
NEXUS adds one convenience: a TRANSLATE table. To keep long trees compact, the TREES block can map each taxon to a number, then use the numbers in the Newick string. So 1,2,3 in the tree might stand for Human, Chimp, Gorilla listed once at the top. It is the one part that trips people up, because the tree appears to be about numbers until you find the table.
Which programs use NEXUS
NEXUS is the native format for MrBayes, PAUP* and Mesquite, and it is widely accepted by BEAST, FigTree and SplitsTree. If a program asks you to load a data matrix and run an analysis in one file, it almost certainly wants NEXUS. Files carry a .nex or .nexus extension.
Newick or NEXUS?
Reach for Newick when you just need to move a tree between programs or paste it into a viewer. Reach for NEXUS when the tree travels with its data and analysis settings, or when the program you are feeding expects it. The full comparison, with a side-by-side of the same tree in both formats, is on Newick vs NEXUS.
Using NEXUS with this tool
You can export NEXUS here: build or import a tree, then choose Export → NEXUS to download a .nex file for MrBayes, PAUP* or Mesquite.
To view a tree that you already have in a NEXUS file, copy the Newick string out of its TREES block (the part in parentheses ending in a semicolon) and paste that into Import Newick. Since the NEXUS tree is Newick inside, this draws it straight away, and from there you can restyle it and export a figure or convert it.
Build yours in the browser, no signup, no install.
Open the cladogram maker