Text to hex, plain and predictable
Text to hex encoding walks every character of your input, reads its UTF-16 char code with charCodeAt, and writes that integer as a base-16 string. ASCII characters (codes 0 through 127) fit in one or two hex digits, Latin-1 characters fit in two, and the rest of the Basic Multilingual Plane fits in up to four. The default behaviour zero-pads every chunk to two digits, which is the form most hex-to-text decoders expect; non-ASCII characters above code 255 expand to a longer chunk because their value does not fit in two hex digits.
Three toggles change the output shape. 0x Prefix, off by default, prepends 0x to every chunk so the output reads as a sequence of C-style literals. Pad Bytes, on by default, zero-pads every chunk to at least two hex digits so the output stays regular for ASCII text. Separate, on by default, puts a single space between every chunk so the output reads as a stream of bytes. Turn it off to emit a continuous run of hex digits with no delimiter.
The three toggles compose. Prefix on plus Separate on emits 0x48 0x65 0x6c. Prefix off plus Separate off emits 48656c. Prefix on plus Separate off emits 0x480x650x6c, which is unusual but valid for some downstream parsers. For the inverse direction, see hex to text.
How to use convert text to hex
- 1Paste your text into the input panel on the left.
- 2The hexadecimal stream appears in the output panel on the right as you type.
- 3Toggle 0x Prefix to prepend
0xto each chunk. - 4Toggle Pad Bytes to zero-pad short chunks to two digits.
- 5Toggle Separate to insert a space between chunks.
Keyboard shortcuts
Drive TextResult without touching the mouse.
| Shortcut | Action |
|---|---|
| Ctrl F | Open the find & replace panel inside the input Plus |
| Ctrl Z | Undo the last input change |
| Ctrl Shift Z | Redo |
| Ctrl Shift Enter | Toggle fullscreen focus on the editor Plus |
| Esc | Close find & replace, or exit fullscreen |
| Ctrl K | Open the command palette to jump to any tool Plus |
| Ctrl S | Save current workflow draft Plus |
| Ctrl P | Run a saved workflow Plus |
What this tool actually does
UTF-16 char codes via charCodeAt
Each character is read with charCodeAt(0), which returns the UTF-16 code unit value. ASCII text encodes to values 0 through 127, Latin-1 to 0 through 255, and the rest of the Basic Multilingual Plane to up to 65535. Above-BMP characters encode as two 16-bit surrogate code units, one chunk each.
0x Prefix toggle (default off)
When on, every chunk is prepended with 0x. So H emits as 0x48 instead of 48. That matches the convention used in C, JavaScript and Go integer literals, and is handy when pasting the result into source code.
Pad Bytes toggle (default on)
On by default. Zero-pads every chunk to at least two hex digits with padStart(2, "0") so ASCII characters always emit a clean byte. Turn off to emit the minimum number of hex digits per character. With padding off, \n (char code 10) emits as a, not 0a.
Separate toggle (default on)
On by default. Inserts a single space between every chunk so the output reads as a stream of bytes. Turn off to emit a continuous run of hex digits with no delimiter. Continuous output needs Pad Bytes on to round-trip without a known chunk width.
Runs entirely in your browser
No upload, no server-side processing, no log of what you pasted. The encode runs on every keystroke via a single JavaScript pass. Long inputs of a few hundred kilobytes still encode in under a second on a desktop browser.
Worked example
Two characters become two two-digit hex chunks: H is char code 72 (48), i is char code 105 (69).
Hi
48 69
Settings reference
| Setting or rule | Effect on output |
|---|---|
| 0x Prefix (default off) | Prepends 0x to every chunk. Useful for pasting into source code. |
| Pad Bytes (default on) | Zero-pads each chunk to at least two hex digits. Turn off to emit minimum width. |
| Separate (default on) | Inserts a single space between chunks. Turn off for a continuous run. |
| Encoding | UTF-16 code unit value of each character via charCodeAt, then toString(16). |
| ASCII characters | Encode in 1-2 hex digits. Pad Bytes on always emits two digits. |
| Above-byte characters | Need more than two hex digits. With padding on, the chunk grows to the next sufficient width. |
| Empty input | Emits an empty string. |
FAQ
Does it work on accented characters?
e is char code 101 (65), e-acute is char code 233 (e9). Both fit in two hex digits, so Pad Bytes on emits two-digit chunks for both. Characters above code 255 need wider chunks, which the converter produces automatically when padding is on.What does 0x Prefix do?
0x so the output reads as a sequence of C-style hex literals. So H emits as 0x48. That matches integer literal syntax in C, C++, JavaScript, Go, Rust and most assembly languages.When should I turn off Pad Bytes?
\n) emits as a instead of 0a. With padding off and Separate off, the result is ambiguous without knowing where each chunk ends.Is the text sent anywhere?
How do I go the other way?
0x prefixes and whitespace, then parses the remaining hex digits as two-digit bytes back to characters.