String to Hex

Produce the hexadecimal bytes behind a piece of text, formatted the way your target expects.

Text
Hex bytes
Runs locally in your browser

About the String to Hex

Hexadecimal is the shortest readable way to write a byte, which is why it shows up in packet captures, escape sequences and test fixtures. This encoder takes your text, converts it to bytes, and prints each one as two hex digits. In UTF-8 mode an ASCII letter is one byte, a Latin letter with an accent is two, and a currency symbol such as the euro sign is three, which is exactly what a network trace would show.

Latin-1 mode instead insists that every character fit in a single byte. That is handy when writing fixtures for a legacy protocol, and any character above 255 stops the conversion with a message naming it rather than truncating quietly.

Formatting covers the layouts you are likely to need. Upper case digits suit documentation and hex dumps, lower case suits most programming languages. The separator can be a space for readability, nothing for a compact blob, a comma for an array literal, or a tab for a spreadsheet column. Ticking the prefix option writes 0x ahead of every byte so the output can be pasted straight into C or Go source. To read a dump back, Hex to String undoes all of this, and Hex Encode offers a leaner interface for quick one off conversions.

How to use

  1. Paste the text you want as hex.
  2. Choose the digit case and the separator that match your target format.
  3. Tick Prefix every byte with 0x for source code output.
  4. Copy the bytes or download them.

Common questions

Why does the euro sign take three bytes?
In UTF-8 it is encoded as E2 82 AC. Only the first 128 characters fit in a single byte.
How do I produce a compact hex blob?
Set the separator to Nothing and the case to lower, which is the form most libraries expect for a hex string.
What happens to a character Latin-1 cannot hold?
The conversion stops and the character is named, so you can switch back to UTF-8 rather than losing data.
Is the output the same as a checksum?
No. This is a reversible encoding of your text, not a hash. Use a hash generator when you need a fingerprint.