Syllable Counter

Counts and hyphenates the syllables of Dutch (and Dutch-spelled international) names and words. No dictionary, no pattern file, no API call. Pure spelling rules, in JavaScript and PHP, with identical output.

Try it

Final e

Whether a final e is spoken cannot be read off the letters: Céline is mute, Eline is not. Override it when you know.

Runs entirely in your browser. The module is imported as a plain ES module, so nothing is sent anywhere.

Two packages, one rule set

The PHP package came first; the JavaScript one is a vanilla port of it. Same rules, same exception list, same test table, so the browser and the server never disagree about a name.

JavaScript

Zero dependencies, plain ES modules, runs in Node ≥ 18 and in the browser with no build step.

npm install @tinusg-npm/syllable-counter
import { hyphenate } from '@tinusg-npm/syllable-counter';

hyphenate('Olivia');  // 'O-li-vi-a'

PHP / Laravel

PHP 8.2+, auto-discovered service provider, publishable config. Resolve it from the container.

composer require tinusg/syllable-counter
use TinusG\SyllableCounter\SyllableCounter;

$counter->hyphenate('Olivia');  // 'O-li-vi-a'

The API

Method Returns Example
count(value, muteFinalE?) Number of syllables, never less than 1 count('Olivia') → 4
split(value, muteFinalE?) The syllables, casing and accents intact split('Sophia') → ['So','phi','a']
hyphenate(value, separator?, muteFinalE?) The hyphenated word hyphenate('Olivia') → 'O-li-vi-a'

count() runs through split(), so counting and hyphenating can never disagree. Spaces and hyphens are word boundaries: Anne-Marie is 4.

How it works

One rule carries the whole thing: a syllable has exactly one vowel nucleus. Find the nuclei, divide the consonants between them, and you have both the count and the hyphenation.

  1. Normalise, but remember the accents. é → e, but the position stays flagged, which is why Chlo-ë and Chlo-é split where Loes does not.
  2. Find the nuclei. Trigraphs (aai, eeu, eau) and digraphs (ie, ei, ui, ou, ij, …) are one nucleus; anything else adjacent is a hiatus and counts twice. That is what gets So-phi-a and An-to-ni-o right where naive vowel-group counters collapse them.
  3. Maximal onset. As much of the consonant cluster as can form a valid Dutch onset moves to the following syllable: An-dre-a, not And-re-a; I-sa-bel-la, because ll is no onset.
  4. The final e. A safe heuristic after c and qu (A-lice, Flo-rence), and your own knowledge wins via muteFinalE.
  5. Exceptions, last. A short list for the names that break every rule (James is one syllable), and you can pass your own.

It produces orthographic hyphenation, not a phonetic transcription, and it is tuned for names. Full write-up in the JS README.

Where it comes from

Both packages were extracted from the code that powers two Dutch sites, and they exist because those sites needed them:

Naampedia

Baby names: meanings, origins and popularity. The syllable rules were written for its name pages and tested against tens of thousands of real first names.

Puzzelpedia

A puzzle dictionary and solving aid, where counting syllables and splitting words is daily business.

If a package is useful to you, a link back to naampedia.nl and puzzelpedia.nl, in your README, your credits page or wherever you list what you build on, would be very much appreciated. That is the whole price.