Introduction
hangul.dev is a technical reference for working with Hangul (Korean script) in software. This documentation covers Unicode encoding, syllable composition algorithms, jamo decomposition, and practical code examples for processing Korean text.
Hangul is one of the most systematically designed writing systems in the world. Created in 1443 by King Sejong the Great, its structure maps directly to computational models: consonants and vowels (jamo) compose into syllable blocks following strict rules that are elegantly represented in Unicode.
Hangul Basics
Consonants (자음)
Hangul has 14 basic consonants, each depicting the shape of the speech organ used to produce it. Additional consonants are formed by adding strokes to these base forms.
Vowels (모음)
Hangul vowels are constructed from three philosophical elements: a dot (heaven), a horizontal line (earth), and a vertical line (humanity). These combine to form 10 basic vowels.
Unicode Overview
Hangul characters occupy several blocks in the Unicode Standard:
| Block | Range | Count | Description |
|---|---|---|---|
| Hangul Jamo | U+1100..U+11FF |
256 | Conjoining jamo for algorithmic composition |
| Hangul Compatibility Jamo | U+3130..U+318F |
96 | Standalone jamo for display |
| Hangul Syllables | U+AC00..U+D7AF |
11,172 | Precomposed syllable characters |
| Hangul Jamo Extended-A | U+A960..U+A97F |
32 | Old Korean initial consonants |
| Hangul Jamo Extended-B | U+D7B0..U+D7FF |
80 | Old Korean vowels and final consonants |
Jamo Block
Initial Consonants (Choseong)
The 19 initial consonants used in syllable composition, indexed 0-18:
Medial Vowels (Jungseong)
The 21 medial vowels used in syllable composition, indexed 0-20:
Final Consonants (Jongseong)
The 28 final consonant positions (index 0 = no final), indexed 0-27:
Syllable Composition
The Unicode Hangul Syllable Composition algorithm computes a syllable character from its jamo components using a simple formula:
syllable = 0xAC00 + (initial * 21 + medial) * 28 + final
where:
initial = index of choseong (0-18)
medial = index of jungseong (0-20)
final = index of jongseong (0-27, 0 = none)
Example: Composing 한
0xAC00 + (18 * 21 + 0) * 28 + 4
= 0xAC00 + (378) * 28 + 4
= 0xAC00 + 10584 + 4
= 0xAC00 + 0x2958 + 0x4
= 0xD55C
= 한
Decomposition
To decompose a Hangul syllable character back into its jamo components, reverse the composition formula:
function decomposeHangul(syllable) {
const code = syllable.charCodeAt(0) - 0xAC00;
if (code < 0 || code > 11171) return null;
const initial = Math.floor(code / (21 * 28));
const medial = Math.floor((code % (21 * 28)) / 28);
const final_ = code % 28;
const CHOSEONG = [
'ㄱ','ㄲ','ㄴ','ㄷ','ㄸ','ㄹ','ㅁ','ㅂ','ㅃ',
'ㅅ','ㅆ','ㅇ','ㅈ','ㅉ','ㅊ','ㅋ','ㅌ','ㅍ','ㅎ'
];
const JUNGSEONG = [
'ㅏ','ㅐ','ㅑ','ㅒ','ㅓ','ㅔ','ㅕ','ㅖ','ㅗ','ㅘ',
'ㅙ','ㅚ','ㅛ','ㅜ','ㅝ','ㅞ','ㅟ','ㅠ','ㅡ','ㅢ','ㅣ'
];
const JONGSEONG = [
'','ㄱ','ㄲ','ㄳ','ㄴ','ㄵ','ㄶ','ㄷ','ㄹ','ㄺ',
'ㄻ','ㄼ','ㄽ','ㄾ','ㄿ','ㅀ','ㅁ','ㅂ','ㅄ','ㅅ',
'ㅆ','ㅇ','ㅈ','ㅊ','ㅋ','ㅌ','ㅍ','ㅎ'
];
return {
initial: CHOSEONG[initial],
medial: JUNGSEONG[medial],
final: JONGSEONG[final_] || null
};
}
Try it: Interactive Decomposition
Character Explorer
Browse all 11,172 Hangul syllable characters (U+AC00 to U+D7A3). Click any character to decompose it.
Code Examples
Check if a character is Hangul
function isHangulSyllable(char) {
const code = char.charCodeAt(0);
return code >= 0xAC00 && code <= 0xD7A3;
}
function isHangulJamo(char) {
const code = char.charCodeAt(0);
return (code >= 0x1100 && code <= 0x11FF) ||
(code >= 0x3130 && code <= 0x318F);
}
isHangulSyllable('한'); // true
isHangulSyllable('A'); // false
Count Hangul characters in a string
function countHangul(str) {
return [...str].filter(ch => {
const code = ch.charCodeAt(0);
return code >= 0xAC00 && code <= 0xD7A3;
}).length;
}
countHangul('Hello 세계!'); // 2
API Reference
Constants
| Name | Value | Description |
|---|---|---|
HANGUL_BASE |
0xAC00 |
Start of Hangul Syllables block (가) |
HANGUL_END |
0xD7A3 |
End of Hangul Syllables block (힣) |
CHOSEONG_COUNT |
19 |
Number of initial consonants |
JUNGSEONG_COUNT |
21 |
Number of medial vowels |
JONGSEONG_COUNT |
28 |
Number of final consonant positions (including none) |
Functions
interface HangulComponents {
initial: string; // Choseong jamo
medial: string; // Jungseong jamo
final: string | null; // Jongseong jamo or null
}
function decompose(syllable: string): HangulComponents | null;
function compose(initial: number, medial: number, final?: number): string;
function isHangulSyllable(char: string): boolean;
function isHangulJamo(char: string): boolean;
function getCharacterName(char: string): string;