Grapheme Counter

A simple React web application that accurately counts graphemes in text, including emojis and complex characters.

Features

  • Real-time grapheme counting using Intl.Segmenter for accurate results
  • Multiple text statistics: graphemes, characters, and words
  • Example texts to demonstrate complex grapheme counting
  • Modern UI with TailwindCSS styling
  • Responsive design that works on all devices

What are Graphemes?

Graphemes are the smallest units of a writing system. They can be:

  • Single characters (like "a", "b", "c")
  • Emojis (like "๐Ÿฆ•", "๐ŸŒ‹")
  • Combining characters (like "รฉ" which can be "e" + "ฬ")
  • Complex sequences (like "๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ" which is a family emoji)

For example, "dinosaurs ๐Ÿฆ• ๐ŸŒ‹๐ŸŒดโ˜„๏ธ" contains 14 graphemes: "d", "i", "n", "o", "s", "a", "u", "r", "s", " ", "๐Ÿฆ•", "๐ŸŒ‹", "๐ŸŒด", "โ˜„๏ธ".

Technical Details

  • Frontend: React 18.2.0 with TypeScript
  • Backend: Hono server for serving the app
  • Styling: TailwindCSS
  • Grapheme Counting: Uses Intl.Segmenter with granularity: 'grapheme'
  • Platform: Built for Val Town

Project Structure

โ”œโ”€โ”€ backend/
โ”‚   โ””โ”€โ”€ index.ts              # Hono server entry point
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ””โ”€โ”€ App.tsx           # Main React component with all logic
โ”‚   โ”œโ”€โ”€ index.html            # HTML template
โ”‚   โ””โ”€โ”€ index.tsx             # React entry point
โ””โ”€โ”€ README.md

Usage

  1. Enter text in the textarea
  2. View real-time statistics:
    • Graphemes: The number of visual units
    • Characters: The total character count
    • Words: The number of words
  3. Try the example texts to see complex grapheme counting in action

Example Results

TextGraphemesCharactersWords
"dinosaurs ๐Ÿฆ• ๐ŸŒ‹๐ŸŒดโ˜„๏ธ"14202
"Hello World! ๐Ÿ‘‹"13152
"cafรฉ ๐Ÿต"682
"๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ"171

Browser Compatibility

The app uses Intl.Segmenter which is supported in:

  • Chrome 87+
  • Firefox 102+
  • Safari 15+
  • Edge 87+

For older browsers, it falls back to character counting.

Development

This is a Val Town project. The main entry point is backend/index.ts which serves the React application.

To run locally with Deno:

deno run --allow-net --allow-read backend/index.ts