DevTools Logo

Shannon Entropy Calculator

Shannon Entropy Calculator

Measure bits per symbol, maximum entropy, redundancy, and a per-symbol probability table. Runs in your browser.

Runs in your browser
Try an example

Text to analyze

Entropy report

Can't analyze

Type text to measure its entropy

Nothing leaves your browser. Results update as you type.

Formula

H = −Σ p·log2(p)

Enter text to see the substitution with your numbers.

Compare with a second text

Details

Shannon entropy measures the average surprise of the symbols in your input: H = -Σ p·log2(p). Count characters (grapheme clusters), UTF-8 bytes, words, or lines, then see the probability and self-information of every symbol. Maximum entropy is log2(k) for the k distinct symbols observed, so normalized entropy and redundancy show how far the distribution sits from a perfectly uniform one. The chi-square verdict uses documented heuristic bands, not an exact p-value. Entropy is a weak proxy for password strength: dictionary and pattern attacks dominate. Everything runs locally in your browser.

More examples

Uniform hexadecimal token

0123456789abcdef0123456789abcdef

Each of the 16 hex digits appears twice, so H is exactly 4 bits per symbol — the maximum for 16 equally likely symbols.

A patterned password

password

Eight characters with one repeated letter give about 2.75 bits per symbol; a short input also has too few expected counts for a chi-square verdict.

Emoji in character and byte modes

😀😀

Character mode sees one repeated grapheme with zero entropy, while UTF-8 byte mode sees four repeated bytes and warns that multi-byte characters were split.

    Examples

    Uniform hexadecimal token

    Input
    0123456789abcdef0123456789abcdef
    Output
    Entropy: 4.0000 bits/symbol · Maximum: 4.0000 · Normalized: 1.0000

    Sixteen equally used hex digits reach the theoretical maximum of log2(16) = 4 bits per symbol.

    Patterned password

    Input
    password
    Output
    Entropy: 2.7500 bits/symbol · Distinct symbols: 7 · Chi-square: insufficient data

    The repeated 's' lowers the score, and eight symbols give fewer than five expected counts per symbol.

    Astral emoji in both units

    Input
    😀😀
    Output
    Characters: 1 symbol, 0 bits/symbol · UTF-8 bytes: 4 symbols, 2.0000 bits/symbol

    Byte mode warns that one four-byte emoji becomes four separate byte symbols; character mode counts one grapheme.

    Use cases

    Triage encoded-looking strings

    Compare a candidate token's bits per symbol with the maximum for its alphabet and inspect the symbols dragging the score down.

    Audit generated tokens

    Check that a generated key uses its full alphabet instead of a small subset, and copy the Markdown report into an audit note.

    Verify an entropy calculation

    See the count, probability, self-information, and contribution of each symbol to confirm a hand-computed H value.

    Teach the limits of entropy

    Show that a repeating short password has a low score and that entropy alone does not measure password strength.

    Common mistakes

    Mistake:Treating entropy as a password-strength or randomness certificate.

    Fix:Use it as one signal only; dictionary and pattern attacks dominate, and statistical tests cannot certify cryptographic randomness.

    Mistake:Comparing character-mode and byte-mode numbers without noting the unit.

    Fix:Keep the unit visible: multi-byte characters split into separate UTF-8 bytes in byte mode but count as one grapheme otherwise.

    Mistake:Reading a chi-square verdict from a very short string.

    Fix:Check the expected-count warning. Below five expected occurrences per symbol the verdict is marked insufficient data.

    Frequently asked questions

    How is the Shannon entropy of a string calculated?

    The tool counts how often each symbol appears, divides each count by the total number of counted symbols to get p, and sums -p·log2(p) over the observed symbols. Terms with p = 0 are skipped by convention. The result is bits per symbol; multiplying by the symbol count gives total bits.

    What is the maximum entropy for my input?

    For k distinct observed symbols the maximum is log2(k), reached only when all k symbols are equally frequent. Normalized entropy (H / log2(k)) is 1.0 for a perfectly uniform distribution. With a single distinct symbol log2(1) is 0, so normalized entropy is reported as 0 and marked trivial instead of NaN.

    Why does my emoji string show fewer bits in character mode than in byte mode?

    Character mode counts grapheme clusters, so an emoji with a skin-tone modifier is one symbol. UTF-8 encodes most emoji as four bytes, so byte mode sees four distinct byte values and counts them separately. The tool shows a warning whenever multi-byte characters are split into bytes.

    What does the chi-square verdict tell me?

    It compares observed counts with a uniform expectation of N/k per symbol. The verdict bands are heuristic normal approximations of the chi-square distribution (df + 3σ for uniform, df + 6σ for plausible, with σ = √(2·df)), not exact p-values. When fewer than five symbols are expected per cell the verdict is 'insufficient data' because short strings give noisy results.

    Is my text, token, or password sent anywhere?

    No. The calculation runs entirely in your browser tab: nothing leaves your browser, nothing is uploaded, and the input is not persisted to local storage. You can paste secret-looking strings without sending them to a server.

    References & standards