Skip to tool

Python collections.Counter() Online

Count character frequencies.

The output updates as you type. The tool processes input in your browser.

Worked example

The result counts occurrences of each Unicode code point. A grapheme may span several entries.

Sample input
banana
Sample output
[
  {
    "codepoint": 97,
    "char": "a",
    "count": 3
  },
  {
    "codepoint": 98,
    "char": "b",
    "count": 1
  },
  {
    "codepoint": 110,
    "char": "n",
    "count": 2
  }
]

Using this operation in Python

The interactive result uses JavaScript. Python str stores Unicode text. Encode to bytes when an API expects UTF-8 or another byte representation.

Python reference