pipr.tools

char-freq

Character frequency analysis

# Stats

Try it

stdin0 chars
stdout0 chars

Example

Analyze character frequencies in a pangram

Usage
$ echo "the quick brown fox jumps over the lazy dog" | char-freq
View source
(input) => {
      const freq = {};
      for (const c of input) freq[c] = (freq[c] || 0) + 1;
      return Object.entries(freq)
        .sort((a, b) => b[1] - a[1])
        .slice(0, 30)
        .map(([c, n]) => {
          const display =
            c === "\n" ? "\\n" : c === "\t" ? "\\t" : c === " " ? "␣" : c;
          return `${display.padEnd(4)} ${String(n).padStart(6)}  ${"█".repeat(Math.min(40, Math.round((n / input.length) * 200)))}`;
        })
        .join("\n");
    }

Suggested Pipelines

Related Tools