Shannon Diversity Index Calculator

Turn species counts into Shannon H, evenness, richness, and total abundance.

Biology and LifeUpdated 2026-10-203 min read
Shannon Diversity Index Calculator
Separate counts with commas, spaces, or semicolons. Each value must be greater than zero.
Shannon index H
...
Evenness...
Species richness...
Total individuals...

What it does

The Shannon diversity index turns a list of species counts into one number. It combines two things: how many species are present, called richness, and how evenly the individuals are divided among them, called evenness.

The index comes from information theory. It asks how uncertain you would be about the species of a randomly chosen individual. A community with one dominant species is easy to predict, so it has a low H. A community with many species at similar abundance is hard to predict, so it has a high H.

This page uses the natural-log form, H = -sum(p_i ln p_i), where p_i is the share of individuals in species i. For counts 30, 20, 15, 10, and 5, the total is 80 and H is 1.461. Evenness is H divided by ln(S), where S is the number of species. Here S is 5 and evenness is 0.908.

H is not a complete description of a community. It does not tell you which species are present, whether they are rare or common, or how the sample was collected. It is also sensitive to sample size, because more individuals usually add rare species. Compare samples of similar size and sampling effort, and report richness and evenness alongside H.

How to use

  1. Enter the count for each species, separated by commas, spaces, or semicolons.
  2. Use the same unit for every count, such as individuals, biomass, or density.
  3. Read H first. Higher values mean more diversity in the sample.
  4. Read evenness next. A value near 1 means the species are close to equally abundant.
  5. Check richness and the total count to see what the sample contained.
  6. Compare only samples with similar size and collection methods.

Formula

H = -sum(p_i ln p_i), where p_i = n_i / N. Evenness = H / ln(S).
H
Shannon diversity index, in nats when natural logs are used.
n_i
Count or abundance of species i.
N
Total count across all species.
p_i
Proportion of the total in species i, n_i / N.
S
Species richness, the number of species.
ln
Natural logarithm.

The formula uses natural logs, so H is in nats. Some ecology texts use base 2 and report bits, or base 10. The choice of base changes the number, so compare H values only when they use the same base. A community with one species has H = 0. Evenness is undefined for one species, which is why this page requires at least two counts.

Worked example

Example: counts 30, 20, 15, 10, 5

Five species with counts 30, 20, 15, 10, and 5. Total N = 80.

  1. Proportions: 30/80 = 0.375, 20/80 = 0.250, 15/80 = 0.1875, 10/80 = 0.125, and 5/80 = 0.0625.
  2. Natural logs: ln(0.375) = -0.9808, ln(0.250) = -1.3863, ln(0.1875) = -1.6740, ln(0.125) = -2.0794, and ln(0.0625) = -2.7726.
  3. Products p ln p: -0.3678, -0.3466, -0.3139, -0.2599, and -0.1733. The sum is -1.4615.
  4. Change the sign: H = 1.4615, shown as 1.461.
  5. Evenness: H / ln(5) = 1.4615 / 1.6094 = 0.908.
  6. The tool shows H = 1.461, evenness = 0.908, richness = 5, and total = 80.

Reference table

Shannon H for several communities
CountsTotalHEvenness
50, 501000.6931.000
80, 201000.5000.722
30, 20, 15, 10, 5801.4610.908
60, 20, 10, 5, 51001.1580.720
25, 25, 25, 251001.3861.000

Limits

  • H depends on sample size and sampling effort. More individuals can add rare species and raise H.
  • The index does not identify species or show which ones are rare. Report the counts with H.
  • Evenness is undefined for a single species. This page requires at least two counts.
  • H can be calculated with different log bases. Compare values only when the base is the same.

Common mistakes

  • Using the count instead of the proportion in p ln p.
  • Forgetting the negative sign, which gives a negative H.
  • Comparing H from samples of very different size or effort.
  • Treating H as a complete biodiversity measure. It ignores species identity and conservation value.
  • Mixing individuals and biomass in the same list without saying so.

Try it yourself

Quick checks. Answers sit tucked under each question.

Two species with counts 50 and 50: what are H and evenness?

N = 100. Each p is 0.5, so H = 0.693. Evenness is 0.693 / ln(2) = 1.000.

Counts 40, 30, 20, 10: what are H and evenness?

N = 100. H = 1.280 and evenness = 1.280 / ln(4) = 0.923.

Counts 90 and 10: what are H and evenness?

N = 100. H = 0.325 and evenness = 0.325 / ln(2) = 0.469. The community is dominated by one species.

Questions

What is a good Shannon diversity index?

There is no universal good value. Published studies often report H between 1.5 and 3.5, but the range depends on the community and the sample. Compare sites or dates using the same method.

What is the difference between H and evenness?

H combines richness and evenness into one number. Evenness scales H by its maximum possible value for the number of species, ln(S).

Should I use natural log or log base 2?

Natural log is common in ecology and gives H in nats. Base 2 gives bits. Use the same base for every sample you compare.

Can I use biomass instead of counts?

Yes, as long as you use the same measure for every species and state it. The formula uses proportions, not raw counts.

Why does H increase with sample size?

Larger samples are more likely to include rare species, which adds categories and raises H. Rarefaction or equal sample sizes help with comparisons.

Does H tell me if a species is endangered?

No. H treats all species as interchangeable. A community can have a high H and still contain a species of conservation concern.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.