# Shannon entropy calculator

Measure Shannon entropy locally: bits per character, byte, word, or line, with total information and frequency tables.

## Run it

- **CLI:** `gizza tool entropy-calculator "password"`
- **Web:** https://gizza.ai/tools/entropy-calculator/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/entropy-calculator/tool.json

## Inputs

- `text` — Text to measure _(field)_
- `basis` — Symbol basis _(field)_
- `unit` — Entropy unit _(field)_
- `scope` — Scope _(field)_
- `ignore_case` — Ignore case (A = a) _(field)_
- `ignore_whitespace` — Ignore whitespace symbols _(field)_
- `precision` — Decimal places _(field)_
- `show_frequencies` — Show symbol-frequency table _(field)_
- `top_symbols` — Frequency rows to show _(field)_

## Output

- Entropy report (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `text` — Text to measure
- `basis` — Symbol basis
- `unit` — Entropy unit
- `scope` — Scope
- `ignore_case` — Ignore case (A = a)
- `ignore_whitespace` — Ignore whitespace symbols
- `precision` — Decimal places
- `show_frequencies` — Show symbol-frequency table
- `top_symbols` — Frequency rows to show

Example: `https://gizza.ai/tools/entropy-calculator/?text=password&basis=characters&unit=bits&scope=whole&ignore_case=true&ignore_whitespace=true&precision=4&show_frequencies=true&top_symbols=12`

---

## About this tool

Shannon entropy measures how unpredictable a sequence is from its observed symbol frequencies. If every symbol appears equally often, entropy is high; if one symbol dominates, entropy is low. This calculator reports that value as **entropy per symbol** plus the derived totals people usually need for quick checks: total information, maximum possible entropy for the observed alphabet, efficiency, redundancy, perplexity, and a ranked frequency table.

It is an order-0 frequency calculation. It does **not** understand grammar, keyboard walks, leaked passwords, Markov models, or how an attacker guesses secrets. Use it as a compact information-theory measurement, not as a password-strength guarantee.

### Worked example — `password`

With the default character basis, `password` has eight characters and seven distinct character values because `s` appears twice. The report shows:

```text
Entropy: 2.7500 bits per character
Total information: 22.0000 bits across 8 characters
Distinct characters: 7
Maximum entropy for this alphabet: log2(7) = 2.8074 bits per character
Efficiency: 97.9539% (redundancy 2.0461%)
Perplexity: 6.7272 equally likely characters
```

That number is the entropy of the observed string. It does not mean the word `password` is safe; dictionary knowledge makes it easy to guess.

### Symbol basis

- **Characters** counts Unicode scalar values. This is the usual choice for text keys and passwords.
- **Bytes** counts UTF-8 bytes and produces the familiar 0–8 bits per byte range for binary-like text.
- **Words** counts whitespace-separated tokens, useful for prose or passphrases.
- **Lines** treats each whole line as one symbol, useful for repeated log events or list values.

### Scope and units

The default scope scores the whole input once. Use **Each line** or **Each paragraph** to find which records are repetitive versus varied; the combined report is still printed after the per-part summary.

Bits are base-2 units (shannons). Nats use base *e*, dits use base 10, and trits use base 3. Perplexity stays the effective number of equally likely symbols, regardless of the unit selected.

### Limits and edge cases

- Input is capped at 1 MiB and 20,000 lines/paragraphs for split scopes.
- Precision is 0–10 decimal places; frequency rows are capped at 64.
- Whitespace filtering removes whitespace characters for character/byte mode and blank lines for line mode. Word mode already splits on whitespace.
- A single repeated symbol has 0 entropy but 100% efficiency by convention because the one-symbol distribution is trivially uniform.
- Binary files are better handled by byte-oriented tooling; this page measures pasted text.

## FAQ

<details>
<summary>Is this the same as password strength?</summary>

No. Shannon entropy here is computed only from the symbols in the pasted string. It does not know that `password`, `qwerty`, dates, or dictionary words are common guesses. A random-looking 12-character token and a memorized word can have similar frequency entropy but very different attack resistance. Treat this as a measurement of symbol distribution, not a security score.

</details>

<details>
<summary>When should I choose bytes instead of characters?</summary>

Choose **bytes** when you want the conventional 0–8 bits/byte view or when UTF-8 encoding itself matters. Non-ASCII characters occupy multiple bytes, so byte entropy can differ from character entropy. For human text, characters or words are usually easier to interpret.

</details>

<details>
<summary>What does maximum entropy mean?</summary>

Maximum entropy is the value the input would have if every distinct symbol you observed appeared equally often. For seven distinct characters in bits, it is `log2(7)`. Efficiency is the measured entropy divided by that maximum. High efficiency means the observed counts are close to uniform; it does not prove the data was generated randomly.

</details>

<details>
<summary>Why do two differently ordered strings get the same entropy?</summary>

This calculator uses an order-0 model: it counts how often symbols appear and ignores their order. `abababab` and `aabbaabb` therefore have the same entropy because both contain four `a` and four `b`. If you need sequence predictability, you need a model that considers n-grams or transitions.

</details>

<details>
<summary>What is perplexity?</summary>

Perplexity is `base^entropy`: the effective number of equally likely symbols. An entropy of 2 bits per character has perplexity 4, meaning the distribution behaves like four equally likely characters even if the real alphabet is larger.

</details>

## Related tools

- [Frequency distribution](https://gizza.ai/tools/frequency-distribution/): Build a character, byte, or n-gram frequency table from text or hex, with counts and percentages, ranked most to least frequent — in your browser. Nothing is uploaded.
- [Password Strength Checker](https://gizza.ai/tools/password-entropy/): Estimate a password's entropy in bits and crack time, and flag weaknesses — entirely in your browser. Your password is never sent anywhere, free.
- [Survey Tabulator](https://gizza.ai/tools/survey-tabulator/): Tabulate survey CSV responses into frequency tables and two-way cross-tabs with counts, percentages, and a chi-square test. Free, private, runs in your browser.
- [Bitwise Calculator](https://gizza.ai/tools/bitwise-calculator/): Bitwise calculator: AND, OR, XOR, NOT, shifts, rotates and popcount on 8–64-bit integers in binary, hex, octal or decimal. Free, private, in your browser.
- [Bollinger Bands calculator](https://gizza.ai/tools/bollinger-bands/): Compute Bollinger Bands (SMA plus/minus standard deviations) for a price series, plus %B and bandwidth, in your browser. Free, private, no upload.
