Shannon Diversity Index Calculator

Measure species diversity from the individuals counted for each species.

Handles up to 40 species, natural logs or a custom base, and evenness for two or more species.

Updated November 25, 2026
Frank Zhao - Creator
CreatorFrank Zhao
Loading calculator…

Introduction

A species list with a count beside each name is the most common thing a field survey produces. The Shannon diversity index squeezes that list into one number: how many species the sample holds, and how evenly the individuals are divided among them. This calculator gives you that number together with the four figures you usually need to interpret it.

Type the number of individuals you counted for each species, one row per species. The page then reports the Shannon diversity index, evenness, richness (the number of species), the total number of individuals and the average population size. By default the index is read with the natural logarithm, in nats; untick that box when a report or a comparison study used a different base, and the index is converted for you.

It is a descriptive measure of community structure, not a conservation score. Two communities can return exactly the same index while sharing almost no species, and a sample of common weeds can outscore a rare habitat with fewer species. Use it to describe a sample you have already counted, to compare samples taken the same way, or to check what a published figure implies about the abundance pattern behind it.

Two details decide how the form behaves, and both are worth knowing before you start. Rows open one after another as you fill them, up to 40 species, and a species you did not find can be left blank or entered as 0 — either way it is excluded, so it can never inflate richness. The five results appear only once at least one individual has been recorded, so a form you have not filled in yet stays quiet instead of reporting a misleading zero.

Up to 40 species

One row per species, each holding a count of individuals

Nats by default

Natural logarithm, or a base of your own to match a report

Five figures

Index, evenness, richness, total individuals, average per species

Quick start

One complete run takes four decisions: what to count, how to enter it, which base to read the index in, and which of the five results answers your question.

1

Count individuals per species

The count is individuals, not occurrences, cover or biomass. Count over one defined area, sampling time or trapping effort, and write down what that effort was, because the number is only meaningful next to it. If a species cannot be counted as individuals, it is not a good fit for this index — see the limits below.

2

Enter one row per species

Type the total count for each species into its own row. A new row opens as you move on, so a three-species sample only ever shows three or four boxes. Leave a species you did not record blank; enter 0 if you looked for it and found none. The two are treated the same way in the arithmetic, so neither adds a species to the richness count.

3

Leave the natural logarithm, or choose a base

With the natural-log box ticked, the index is reported in nats. Leave it ticked unless the figure you are matching was calculated in another base; untick it to read the index in bits (base 2) or hartleys (base 10). The base must be a positive number other than 1. The choice rescales the index, not the community, and evenness is unaffected by it.

4

Read the five results

A higher index means a more diverse sample. Evenness is the index expressed as a fraction of its own maximum for that many species, so 1 is a perfectly even sample and values close to 0 mean one species dominates. Richness is simply how many species were found, the total is the sum of every count, and the average population size is that total divided by the number of species.

A first run: three species with 1, 2 and 3 individuals

Three species carry one, two and three individuals. The proportions are therefore a sixth, a third and a half, and the total is six:

NN==1+2+31 + 2 + 3=6= 6
HH==−[16ln⁡16+13ln⁡13+12ln⁡12]-\left[\tfrac{1}{6}\ln\tfrac{1}{6} + \tfrac{1}{3}\ln\tfrac{1}{3} + \tfrac{1}{2}\ln\tfrac{1}{2}\right]≈\approx1.0114 nats1.0114\ \text{nats}
EE==1.0114ln⁡3\frac{1.0114}{\ln 3}≈\approx0.920620.92062

The page reports an index of 1.0114, evenness 0.92062, richness 3, a total of 6 and an average of 2 individuals per species. Evenness this close to 1 says the three species share the sample almost equally; the small deficit comes from the single-individual species carrying less than a third of it.

How the index is calculated

The index is an entropy. Each species contributes the logarithm of its share, weighted by that same share, and the sum is taken with a negative sign so that more species and more even shares produce a larger number.

H=−∑ipiln⁡piH = -\sum_{\mathrm{i}} p_{\mathrm{i}} \ln p_{\mathrm{i}}

Each share is that species' count divided by the total number of individuals in the sample:

pi=niNp_{\mathrm{i}} = \frac{n_{\mathrm{i}}}{N}
HHShannon diversity index in the chosen logarithm base
pip_{\mathrm{i}}Share of the sample made up of species i, its count divided by the total
nin_{\mathrm{i}}Number of individuals counted for species i
NNTotal number of individuals across every species
k\mathrm{k}Richness: how many species hold at least one individual
nˉ\bar{n}Average population size, the total divided by the species count
EEEvenness, the index as a fraction of its maximum for k species
b\mathrm{b}Logarithm base, natural by default; bits use 2, hartleys use 10

A zero row contributes nothing

Species you did not record sit in the sum as zeros, and a zero share would send the logarithm to minus infinity. The limit of that term is zero, which is exactly the behaviour this calculator uses:

piln⁡pi→0p_{\mathrm{i}} \ln p_{\mathrm{i}} \to 0as\quad \text{as} \quadpi→0+p_{\mathrm{i}} \to 0^{+}

So a blank row, a zero row and a species that was simply absent all have the same effect on the index: they are neither counted in richness nor given a term. Only the rows holding at least one individual shape the result.

Richness, total and the average

The three companion figures come straight from the same counts, which is why the index and the rest of the results always agree with each other:

N=∑iniN = \sum_{\mathrm{i}} n_{\mathrm{i}},k=#{ i:ni>0 },\qquad \mathrm{k} = \#\{\,i : n_{\mathrm{i}} > 0\,\},nˉ=Nk,\qquad \bar{n} = \frac{N}{\mathrm{k}}

The average population size is a plain abundance figure, not a diversity one: a sample of one species with fifty individuals averages fifty, and so does a two-species sample of twenty-five each, while their diversity is very different.

Reading the index in bits or hartleys

A logarithm in another base is the natural logarithm divided by the logarithm of that base, so converting an index is a division rather than a different calculation:

Hb=Hln⁡bH_{\mathrm{b}} = \frac{H}{\ln \mathrm{b}}

The one-two-three sample scores 1.0114 nats, which is about 1.4591 bits and 0.4392 hartleys:

H2=1.0114ln⁡2H_{2} = \frac{1.0114}{\ln 2}≈1.4591\approx 1.4591,H10=1.0114ln⁡10,\qquad H_{10} = \frac{1.0114}{\ln 10}≈0.4392\approx 0.4392

The numbers change, the ranking does not: every community's index is scaled by the same factor, so within one base the order of samples is preserved. What you cannot do is compare a figure in nats with a figure in bits — always state the base alongside the index.

Evenness and its maximum

The index has no fixed upper limit, because the maximum grows with the number of species. That maximum is reached when every species holds exactly the same number of individuals, and it equals the natural logarithm of the species count. Evenness divides the index by it, which puts every sample on a zero-to-one scale:

Hmax=ln⁡kH_{\mathrm{max}} = \ln \mathrm{k},E=HHmax=Hln⁡k,\qquad E = \frac{H}{H_{\mathrm{max}}} = \frac{H}{\ln \mathrm{k}}

Because both the index and its maximum are measured in the same base, the base cancels out of the ratio: evenness from a bits calculation equals evenness from nats, to the last digit. A single species has ln⁡1=0\ln 1 = 0 as its maximum, so the ratio is undefined with only one species; that is why the evenness figure appears only once a second species has individuals.

Turning the index into a species count

Raw indices are hard to compare across samples of different richness. A useful reading is to ask how many equally common species would produce the same index, which is the exponential of the index:

eH=number of equally common species with the same indexe^{H} = \text{number of equally common species with the same index}

The one-two-three sample scores 1.0114 nats, so it behaves like about 2.75 species of equal abundance, not the three that are actually present. A perfectly even sample returns its own species count, because there H=ln⁡kH = \ln \mathrm{k} and the exponential undoes the logarithm. Comparing these effective counts is often clearer than comparing raw indices, especially when one site holds many rare species and another holds a few dominant ones.

Comparing two communities

A single index tells you little on its own. The two samples below are the same size, hold the same number of species and come from the same kind of pond, so the only thing that changes is how the individuals are divided among the species.

1

Pond A: three species, perfectly even

Situation: Thirty tadpoles were netted and identified: three species, ten individuals each. Nothing dominates the catch.

Inputs

Species 110 individuals
Species 210 individuals
Species 310 individuals
Sampling effort30 individuals, one netting pass

Result

HH==ln⁡3\ln 3≈\approx1.09861 nats1.09861\ \text{nats}

Evenness is 1, richness is 3, the total is 30 and the average population size is 10.

In practice: This is the evenness ceiling for three species: with every species holding exactly the same share, no other three-species sample can score higher.

2

Pond B: the same three species, one of them dominant

Situation: A second pond yields the same thirty individuals across three species, but this time the catch is 24, 4 and 2. One species holds four fifths of every individual counted.

Inputs

Species 124 individuals
Species 24 individuals
Species 32 individuals
Sampling effort30 individuals, one netting pass

Result

p=0.8, 0.1333, 0.0667p = 0.8,\ 0.1333,\ 0.0667
HH==−[0.8ln⁡0.8+0.1333ln⁡0.1333+0.0667ln⁡0.0667]-\left[0.8\ln 0.8 + 0.1333\ln 0.1333 + 0.0667\ln 0.0667\right]≈\approx0.627705 nats0.627705\ \text{nats}
EE==0.627705ln⁡3\frac{0.627705}{\ln 3}≈\approx0.5713620.571362

As effective species counts, Pond A behaves like 3 equal species and Pond B like about 1.87.

In practice: Richness and total abundance are identical to Pond A, so the difference in the index comes entirely from dominance. Report evenness beside the index and a reader can see that immediately.

Both ponds return a richness of 3, so a species list alone would call them equally diverse. The index and evenness do not. That is the situation this calculator is most useful for: a quick check of whether a difference between two samples is about how many species are present or about how the individuals are shared among them.

Notice also what stays the same across the logarithm bases. In bits the two indices are about 1.5850 and 0.9056; every value is smaller than its nats counterpart by the same factor ofln⁡2\ln 2, and Pond A still outranks Pond B. The evenness figures do not move at all.

Counting rules that change the result

Most disagreement between two diversity figures comes from how the samples were counted, not from the arithmetic. These are the decisions worth writing down before you start.

Keep the sampling effort comparable

A larger sample usually contains more of the rare species, so richness rises and the index rises with it. If two samples differ in area, time or trap count, part of the difference in diversity is simply effort. Compare samples taken the same way, or compare evenness, which is a ratio and therefore less dependent on how many species happened to turn up.

Decide how to count colonies and clones

A coral colony, a clonal grass patch or a bryozoan mat is not obviously one individual. Pick a rule — a colony counts as one, a shoot counts as one, a quadrat presence counts as one — and apply it to every species and every visit. Changing the rule between samples changes the index more than most ecological differences do.

Be consistent about identification level

Lumping two similar species into one row, or splitting one species into two morphotypes, changes the species count and therefore both the index and evenness. Whatever resolution you use, use the same one across the samples you intend to compare, and mention it when you report the result.

Blank and zero are the same thing

A row you never filled in and a row holding 0 are both excluded from richness and from the sum. Neither is treated as a species with zero individuals in the index. Use 0 when you want the record to show that a species was searched for and not found; it will not change the numbers.

Respect the 40-species ceiling

The form offers 40 rows. A sample with more species has to be compressed to fit, usually by grouping rare species into a single row, and that lowers both richness and the index. If your species list is longer than 40, either work at a coarser taxonomic level throughout, or compute the index outside this page and keep the 40-species figure as a separate, clearly labelled summary.

Counts from a forest plot?

A tree survey often produces two products: the species counts you enter here and the stand's size structure from the measured trunk diameters. The basal area calculator turns diameter at breast height into basal area for a single tree or a whole plot, so the diversity figure and the stand density can be reported together.

Questions

Q

Can I enter percentage cover instead of counts?

Not if you want the results labelled as they are. The index itself would still produce a number from cover shares, but richness, total individuals and average population size would no longer describe individuals, and evenness would describe the cover distribution rather than the abundance of organisms. Count individuals when you can; when you only have cover, treat the index as a stand-in and say so wherever you report it.

Q

Why does evenness disappear when only one species is present?

Evenness divides the index by the maximum it could reach for that many species, and with one species that maximum is ln⁡1=0\ln 1 = 0. The ratio is therefore undefined, even though the index itself is a perfectly meaningful 0 — a one-species community has no diversity to divide. The box stays hidden until a second species has individuals, rather than showing a misleading 0 or an error.

Q

Does the logarithm base change which community is more diverse?

No. The base only rescales the index: every sample is divided byln⁡b\ln \mathrm{b}, so a sample that scores higher in nats also scores higher in bits. What you must not do is compare a figure in nats with a figure in bits, because the same community would produce two different numbers. Evenness is not affected at all, since the base cancels between the index and its maximum.

Limits and sampling caveats

  • It is a sample statistic, not a census. Both richness and the index tend to rise as you count more individuals, because a larger sample has a better chance of meeting the rare species. Two visits with different effort are not directly comparable, and a single visit cannot establish that one site is more diverse.
  • Some organisms are not countable as individuals. Clonal plants, colonial invertebrates, filamentous algae, lichens and most microbial data resist the head-count the index assumes. Cover, biomass or presence in a quadrat are legitimate measurements, but the resulting number is a different quantity and should be described as such.
  • No confidence interval, no significance test. The page reports the index of the counts you entered. Whether two indices differ by more than sampling noise is a separate question, answered by replicate samples and a statistical test rather than by comparing two point values.
  • Equal indices do not mean equal communities. The index rewards many species and even abundances; it knows nothing about rarity, endemism, functional distinctiveness or conservation status. A species-poor community of common species and a species-poor community of protected species can return the same figure.
  • Not a regulatory or impact assessment. Permitting, environmental impact work and monitoring programmes require a defined sampling design, replicate plots or traps, a specified taxonomic resolution and an analysis matched to the regulator's method. Use this page for a first look at counts you already have, and have a biodiversity specialist or statistician sign off anything that goes into a formal assessment.
Shannon Diversity Index Calculator - Evenness and Species Richness