Skip to content

Text to Hex Converter

Convert text into hexadecimal bytes using UTF-8 encoding instantly. Choose uppercase, separators, or a 0x prefix per byte.

Separator:

How to Convert Text to Hex

Converting text to hexadecimal encodes the underlying bytes of each character:

  1. Encode the text as UTF-8 bytes
  2. Take each byte value, which ranges from 0 to 255
  3. Write each byte as two hexadecimal digits (00 to FF)
  4. Join the byte pairs with your chosen separator

Example: Convert Hi to hex:

  • H = 72 = 0x48
  • i = 105 = 0x69
  • Result: 48 69

Code Examples

const text = "Hi";
[...new TextEncoder().encode(text)]
  .map((b) => b.toString(16).padStart(2, "0"))
  .join(" "); // "48 69"

Frequently Asked Questions

How do I convert text to hex?

Each character is encoded to one or more UTF-8 bytes, and each byte is written as two hex digits. For example, Hi becomes 48 69.

What separator options are available?

You can output bytes separated by spaces, commas, a 0x prefix on each byte, or with no separator as one continuous hex string. Uppercase output is also optional.

Is text to hex the same as ASCII to hex?

For basic English letters, digits, and punctuation, UTF-8 matches ASCII, so the hex values are identical. Characters outside ASCII use two to four UTF-8 bytes.

How many hex characters does each letter use?

Each byte is exactly two hex digits. Standard ASCII characters are one byte (two hex digits), while emoji and many accented characters take two to four bytes.

Related Tools