Text to Binary / Hex
Convert text to binary, hexadecimal, octal, and decimal encodings.
About this tool
Understanding how text is encoded as numbers is fundamental to computer science. Every character you type—from letters and numbers to symbols and accented letters—is converted into numerical codes for storage and transmission in digital systems. This tool reveals that process by converting text into multiple numerical formats: binary (base-2), hexadecimal (base-16), octal (base-8), and decimal (base-10). While binary is the native language computers use, hexadecimal is widely preferred in programming and system administration for its compact readability.
Whether you're learning computer science, debugging character encoding problems, or preparing for a coding interview, this tool provides immediate, practical feedback. Enter any text and instantly see its representation in all four numeral systems. You can also reverse the process by pasting encoded values to recover the original text. The flexible separator options (space, dash, or no separator) make the output compatible with different formats you might encounter in real-world applications, APIs, and educational materials.
This converter deepens your grasp of how information is fundamentally represented in computing, making it especially valuable for students, CTF competition participants, web developers troubleshooting encoding issues, and anyone curious about the layers beneath digital communication. By visualizing the relationship between human-readable text and machine-level numerical representation, you gain insight into character sets, Unicode, and the ingenious design of modern text encoding standards.
Frequently Asked Questions
Code Implementation
def text_to_binary(text: str, sep: str = " ") -> str:
"""Convert text to binary string (UTF-8 byte representation)."""
return sep.join(f"{byte:08b}" for byte in text.encode("utf-8"))
def binary_to_text(binary: str) -> str:
"""Convert binary string (space-separated 8-bit groups) back to text."""
groups = binary.strip().split()
byte_values = [int(g, 2) for g in groups]
return bytes(byte_values).decode("utf-8")
# Examples
original = "Hello, World!"
binary = text_to_binary(original)
print(f"Text : {original}")
print(f"Binary : {binary}")
print(f"Decoded : {binary_to_text(binary)}")
# Extended ASCII and Unicode
print()
for char in ["A", "z", "0", "@", "é", "中"]:
b = text_to_binary(char)
print(f" {char!r:6} -> {b}")
# Hexadecimal comparison
print()
for byte in "Hi".encode("utf-8"):
print(f" {byte:3d} 0x{byte:02X} {byte:08b}")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.