Morse Code Converter
Convert text to Morse code and decode Morse code back to text.
Reference
0
−−−−−
1
·−−−−
2
··−−−
3
···−−
4
····−
5
·····
6
−····
7
−−···
8
−−−··
9
−−−−·
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
−−··
About this tool
Morse code is a timeless encoding system that represents letters and numbers as sequences of dots and dashes, separated by pauses. Originally developed for telegraph communication in the 19th century, it remains invaluable for emergency signaling, amateur radio operators, and anyone interested in classical communication methods. This converter transforms ordinary text into Morse code instantly and can decode Morse sequences back into readable text.
To use this tool, simply type or paste your message in the text field and click the Convert button to see the Morse code output with appropriate spacing between characters and words. For decoding, paste your Morse code using the standard format—dots represented as periods or hyphens, and dashes as longer sequences—and the tool will translate it back to regular text. This makes it easy to learn and practice Morse code without specialized equipment or prior experience.
Frequently Asked Questions
Code Implementation
# Morse Code Encoder / Decoder
MORSE_CODE = {
'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': '--..',
'0': '-----', '1': '.----', '2': '..---', '3': '...--',
'4': '....-', '5': '.....', '6': '-....', '7': '--...',
'8': '---..', '9': '----.',
'.': '.-.-.-', ',': '--..--', '?': '..--..', '/': '-..-.',
}
REVERSE_MORSE = {v: k for k, v in MORSE_CODE.items()}
def encode(text: str) -> str:
"""Convert plain text to Morse code."""
result = []
for word in text.upper().split():
coded_word = ' '.join(MORSE_CODE.get(ch, '?') for ch in word)
result.append(coded_word)
return ' / '.join(result) # '/' separates words
def decode(morse: str) -> str:
"""Convert Morse code back to plain text."""
words = morse.strip().split(' / ')
result = []
for word in words:
letters = [REVERSE_MORSE.get(sym, '?') for sym in word.split()]
result.append(''.join(letters))
return ' '.join(result)
# Examples
print(encode("SOS")) # ... --- ...
print(encode("HELLO WORLD")) # .... . .-.. .-.. --- / .-- --- .-. .-.. -..
print(decode("... --- ...")) # SOS
print(decode(".... . .-.. .-.. --- / .-- --- .-. .-.. -..")) # HELLO WORLDComments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.