Binary / Text Converter
Convert plain text to binary, hexadecimal, octal, or decimal — and back — with a per-character breakdown.
About this tool
Type any text and instantly see its binary (8-bit), hexadecimal, octal, or decimal (ASCII code) representation. Switch between four direction tabs: Text → Binary, Text → Hex, Text → Octal, and Text → Decimal. A character-by-character breakdown table shows each letter alongside its code in the selected base. All conversion is real-time as you type, and a copy button lets you grab the output instantly.
How to use
- 1 Select a conversion tab: Binary, Hexadecimal, Octal, or Decimal.
- 2 Type or paste text in the input area to see the encoded output instantly.
- 3 Or paste encoded values in the output area to decode back to text.
- 4 Use the Copy button to copy the result, and the breakdown table for per-character details.
How text becomes numbers
Computers store no letters — only numbers. Text is turned into numbers by a character encoding, a lookup table that assigns each character a numeric code. The capital letter H is code 72, lowercase i is 105, a space is 32. This tool reads each character's code with the browser's charCodeAt function and then expresses that code in whichever base you choose: binary (base 2), hexadecimal (base 16), octal (base 8), or plain decimal. Converting "text to binary" is really two steps: text to numbers via the character table, then numbers to binary digits.
The four bases, and why each exists
| Base | Digits used | H (code 72) becomes | Why it's used |
|---|---|---|---|
| Binary (2) | 0–1 | 01001000 | How hardware actually stores data |
| Octal (8) | 0–7 | 110 | Compact in older Unix systems |
| Decimal | 0–9 | 72 | Human-readable code points |
| Hexadecimal (16) | 0–9, A–F | 48 | Two digits per byte, compact |
Hexadecimal is popular because one byte (eight bits) maps neatly to exactly two hex digits, so 48 is far easier to read and type than 01001000. Octal groups bits in threes, which suited early word sizes. Binary is the underlying truth; the others are just shorter ways of writing the same value.
Why binary outputs are padded to 8 digits
The number 72 in binary is 1001000 — only seven digits. But this tool pads every binary byte to eight digits, producing 01001000, because a byte is by definition eight bits. The leading zero carries no value mathematically, yet it keeps every character the same width so a decoder can slice the stream into clean 8-bit chunks. Hexadecimal is padded to two digits and octal to three for the same reason: fixed-width fields are unambiguous to read back. Decimal is left unpadded because its values are separated by spaces, not by position.
A worked example: encoding "Hi"
Type Hi and switch to Binary mode. The tool processes each character in turn:
H→ code 72 → in binary 64 + 8 =01001000i→ code 105 → in binary 64 + 32 + 8 + 1 =01101001
The output is 01001000 01101001, space-separated. The character breakdown table below shows each character, its numeric code, and its encoded form side by side, so you can see exactly where each group of bits comes from. Switch the same input to hex and you get 48 69; to octal, 110 151; to decimal, 72 105.
Decoding back to text
Press the swap button to reverse direction. Now the tool reads space-separated tokens, parses each one in the chosen base with parseInt, and feeds the resulting code into String.fromCharCode to recover the character. Paste 01001000 01101001 in binary mode, swapped to decode, and you get Hi back. If a token is not valid in the current base — say you paste a 2 while in binary mode — the tool reports the offending token rather than producing silent garbage.
Common mistakes
- Mixing up the base. The string
110means 6 in binary, 72 in octal, and 110 in decimal. Always decode in the same base the data was encoded in. The tool's tab must match the format you are pasting. - Dropping the spaces. Decoding relies on whitespace to separate one character's code from the next. Pasting
0100100001101001with no spaces leaves the decoder unable to find the byte boundaries. - Expecting it on big numbers. This is a character converter, not a general number-base converter. It turns text into the codes of its characters, so feeding it a single large number will encode each digit as a character, not convert the number itself.
- Forgetting non-ASCII limits. Decoding uses
fromCharCodeon each token, which works cleanly for standard ASCII (codes 0–127). Characters outside the basic range can involve multi-unit encodings that a simple per-token decode does not reassemble.
Where this is useful
- Learning how encoding works. Seeing "Hi" expand into bits demystifies what "everything is just ones and zeros" really means.
- Puzzles and CTFs. Capture-the-flag challenges and escape-room clues frequently hide messages as binary or hex strings.
- Quick debugging. Spotting a stray control character by inspecting the decimal codes of a short string.
- Teaching number bases. The breakdown table is a ready-made worksheet showing the same value across four representations.
All conversion happens in your browser with built-in JavaScript functions — nothing you type is uploaded, so the tool works offline and your text stays on your device.