Text ⇄ Binary / Hex
Text to binary, hex, octal or decimal, and back.
About Text ⇄ Binary / Hex
Convert text to binary, octal, decimal or hexadecimal character codes, and decode a list of codes back into text. Results appear as you type, in the browser.
How to use
- With the direction set to Text → codes, type or paste text. All four bases appear at once, each with a Copy button.
- Pick the encoding: UTF-8 bytes (one number per byte) or UTF-16 units (one number per 16-bit code unit, the value JavaScript's charCodeAt gives).
- Switch to Codes → text, pick the base the numbers are written in (default binary), and paste the codes separated by spaces or commas. The decoded text appears in the output.
- Changing direction clears the input.
What it produces
- With UTF-8 bytes, one number per byte: ASCII characters give one,
égives two (C3 A9) and most emoji give four. With UTF-16 units, one number per code unit:égivesE9and an emoji gives a surrogate pair such asD83D DE00. For ASCII text the two are identical. - Codes are not zero-padded:
His1001000in binary, not01001000, and hex digits are upper case with no0xprefix. - When decoding, tokens may be separated by spaces or commas; a single unseparated binary or hex string is cut into 8-bit (UTF-8) or 16-bit (UTF-16) units. Each token must contain only digits valid in the chosen base; the first invalid token is named in the error.
- UTF-8 decoding rejects values above
FFand byte sequences that are not valid UTF-8. UTF-16 decoding joins surrogate pairs, also accepts a full code point such as1F600, and rejects anything above10FFFF.
Example
Hello
→ Binary 1001000 1100101 1101100 1101100 1101111
→ Octal 110 145 154 154 157
→ Decimal 72 101 108 108 111
→ Hexadecimal 48 65 6C 6C 6F
Privacy
Conversion runs in the page. No request is made and nothing is stored.
Frequently asked questions
- How do I convert text to binary?
- Look up each character's code (A is 65, a is 97) and write that number in base 2. "Hi" becomes 1001000 1101001; pad each group to eight digits if you want byte-aligned output.
- What is the difference between ASCII and Unicode?
- ASCII defines 128 characters with codes 0 to 127. Unicode extends the same first 128 codes to over 149,000 characters; UTF-8 and UTF-16 are the encodings that turn those code points into bytes.
- Why does an emoji produce two or four numbers?
- Characters above U+FFFF need four bytes in UTF-8 (F0 9F 98 80 for 😀) and a surrogate pair of two 16-bit units in UTF-16 (D83D DE00). Pick the encoding that matches the system you are talking to.
- Why is "Hello" in hex 48 65 6C 6C 6F?
- Those are the ASCII codes of H, e, l, l and o (72, 101, 108, 108, 111) written in base 16. Hex is the usual way to show bytes because every byte fits in exactly two hex digits.