Translate text to Morse code or decode Morse back to text — output updates as you type. Switch direction with one click, then copy the result.
Output appears as you type
Invented by Samuel Morse and Alfred Vail in the 1830s for the electrical telegraph, Morse code revolutionized long-distance telecommunications. International Morse code encodes text characters as standardised sequences of short and long signals, known respectively as dots (or dits) and dashes (or dahs).
The duration of a dot constitutes the fundamental unit of time measurement in Morse code:
$$\text{Duration of 1 Dash} = 3 \times \text{Duration of 1 Dot}$$
| Morse Code Element | Relative Duration | Standard Character |
|---|---|---|
| Dot (dit) | 1 unit | . |
| Dash (dah) | 3 units | - |
| Inter-element gap (between dots/dashes in character) | 1 unit | Space |
| Short gap (between letters within a word) | 3 units | Single space / delimiter |
| Medium gap (between distinct words) | 7 units | / or triple space |
| Character | Morse Code | Character | Morse Code | Digit | Morse Code |
|---|---|---|---|---|---|
| A | .- | N | -. | 0 | ----- |
| B | -... | O | --- | 1 | .---- |
| C | -.-. | P | .--. | 2 | ..--- |
| D | -.. | Q | --.- | 3 | ...-- |
| E | . | R | .-. | 4 | ....- |
| S | ... | T | - | 5 | ..... |
| SOS | ... --- ... (Distress signal sent without inter-character pauses) |
JavaScript
const MORSE_MAP = {
A: '.-', B: '-...', C: '-.-.', D: '-..', E: '.', F: '..-.',
G: '--.', H: '....', I: '..', J: '.---', K: '-.-', L: '.-..',
M: '--', N: '-.', O: '---', P: '.--.', Q: '--.-', R: '.-.',
S: '...', T: '-', U: '..-', V: '...-', W: '.--', X: '-..-',
Y: '-.--', Z: '--..', ' ': '/'
};
function encodeToMorse(text) {
return text.toUpperCase().split('')
.map(ch => MORSE_MAP[ch] || '')
.filter(Boolean)
.join(' ');
}
console.log(encodeToMorse("HELLO WORLD"));
// .... . .-.. .-.. --- / .-- --- .-. .-.. -..
This website and utility are provided for general informational, calculation, and educational purposes only. Always verify critical computation outputs prior to professional deployment or financial use. See our Terms of Service and Privacy Policy for full governance details.