King Sejong's Hunminjeongeum gave consonants and vowels their own independent letterforms, then designed a rule for stacking them — an initial consonant, a medial vowel, and an optional final consonant (batchim) — into a single square-ish block per syllable. Instead of stringing letters horizontally like the Latin alphabet, Hangul stacks them within one syllable's footprint.
This composition rule is baked directly into Unicode's precomposed Hangul block (U+AC00–U+D7A3, 11,172 characters). Given an index into 19 initials (ㄱ–ㅎ), 21 medials (ㅏ–ㅣ), and 28 finals (including "none"), the formula `0xAC00 + (initialIndex × 21 + medialIndex) × 28 + finalIndex` gives the exact code point — and running it backwards decomposes any syllable into its three jamo.
That arithmetic is what makes jamo-level search (typing "ㄱㅅㅎ" to match "감사합니다"), dual/triple-layout Korean keyboards, and jamo-decomposition animation easier than in most writing systems. The demo decomposes "한" into initial ㅎ, medial ㅏ, final ㄴ, then actually computes the formula to recombine them.
When to use
Reach for this formula when you need to manipulate syllables programmatically — jamo-based search, IME logic, or debugging font rendering.