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
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.
- Normalise, but remember the accents.
é→e, but the position stays flagged, which is whyChlo-ëandChlo-ésplit whereLoesdoes not. - 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 getsSo-phi-aandAn-to-ni-oright where naive vowel-group counters collapse them. - Maximal onset. As much of the consonant cluster as can form a valid Dutch onset moves
to the following syllable:
An-dre-a, notAnd-re-a;I-sa-bel-la, becausellis no onset. - The final e. A safe heuristic after
candqu(A-lice,Flo-rence), and your own knowledge wins viamuteFinalE. - Exceptions, last. A short list for the names that break every rule (
Jamesis 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.