Cladogram Maker
Home/The NEXUS format, explained

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:

#NEXUSBEGIN TAXA;  A  B  CBEGIN TREES;  tree = ((A,B),C);END;ABC
A NEXUS file is a container. The header names the format, and each block holds one kind of data. The TREES block stores the tree itself as a Newick string, shown in blue with the tree it draws.

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

Frequently asked questions

What is the NEXUS format?
NEXUS is a plain-text container format for phylogenetics. It begins with a #NEXUS header and holds labelled blocks such as TAXA (the taxon list), DATA or CHARACTERS (the matrix) and TREES (one or more trees written as Newick). Files end in .nex or .nexus.
What is the difference between NEXUS and Newick?
Newick is a single tree on one line. NEXUS is a container that can hold that same tree plus the taxon list, a data matrix and analysis settings, all in blocks. A NEXUS TREES block stores its tree as Newick, so NEXUS is essentially Newick with a structured wrapper.
What programs use NEXUS files?
NEXUS is the native format for MrBayes, PAUP* and Mesquite, and it is read by BEAST, FigTree and SplitsTree, among others. Programs that load a data matrix and run an analysis from one file typically expect NEXUS.
What is a TRANSLATE table in a NEXUS tree?
It is an optional map inside the TREES block that assigns each taxon a number, so the Newick string can use short numbers instead of full names. You read the tree by swapping each number back for its taxon from the table.
How do I open or convert a NEXUS file?
To view the tree, copy the Newick string from the file's TREES block and paste it into Import Newick on this site. To create a NEXUS file, build or import a tree here and use Export NEXUS.