Hex Encode

Convert text to its hexadecimal byte representation, with optional uppercase and space-separated output. UTF-8 aware, runs entirely in your browser.

Loading tool…

Worked examples

  • A short plain-text string

    The everyday case: every byte becomes exactly two hex digits, so the output is always twice the input's byte length.

  • Uppercase hex with a space between bytes

    Uppercase, space-separated hex is the format most hex editors and byte-array literals in C-like languages expect.

  • Text with a multi-byte UTF-8 character

    The accented é encodes as two UTF-8 bytes (c3 a9), not one — the byte count is always what the hex reflects, not the character count.

What this tool does

Hexadecimal (hex) encoding represents each byte of data as two hexadecimal digits, giving a compact, human-readable view of raw bytes using only the characters 0-9 and a-f. This tool converts text to its hex byte representation entirely in your browser, with options for uppercase digits and space-separated bytes.

When you need it

  • Reading or writing raw byte values in a debugger, network packet inspector, or firmware tool that displays data as hex.
  • Building a byte-array literal for C, C++, Rust or similar languages, which commonly use hex escapes like \x48\x69.
  • Comparing a piece of text's exact byte content against a reference value, when whitespace or invisible characters make plain-text comparison unreliable.
  • Understanding what a hex string found in a config file, log, or protocol trace actually spells out, using the companion Hex Decode tool.

How the encoding works

  1. Text is encoded as UTF-8 bytes first. This is the same first step as Base64 encoding — a character and a byte are not the same thing once non-ASCII characters are involved, since accented letters, symbols and emoji take two to four bytes each in UTF-8.
  2. Each byte becomes exactly two hex digits, using values 00 through ff. This means the hex output is always exactly twice as long, in characters, as the number of input bytes.
  3. The uppercase option switches the digits a-f to A-F. Both are valid hex; the choice is purely about matching the convention of whatever system you're pasting the result into — some hex editors and languages default to uppercase, others to lowercase.
  4. The space-delimiter option inserts a single space between each byte pair, which is how most hex editors display memory or file contents, and makes long strings easier to scan visually. The no-delimiter option produces one continuous token, better suited for pasting into code as a single string literal.

Why byte count matters more than character count

If you're expecting a hex string to represent a specific number of bytes — say, matching a 16-byte encryption key or a 4-byte checksum — remember that character count in the original text isn't the same as byte count once you're outside plain ASCII. A 4-character string with one accented letter can produce 5 or more bytes, and therefore 10 or more hex characters. The tool reports both the input byte count and the output character count so you can check this directly rather than assuming.

Things to check after encoding

  • If a system rejects your hex string as the wrong length, check whether it's expecting a specific byte count (like exactly 16 or 32 bytes for a key) rather than just "some hex."
  • Hex encoding, like Base64, is not encryption or compression — it makes bytes readable as text, but anyone can decode it back instantly. Don't use it to hide anything sensitive.
  • If you need a shorter text representation of the same bytes, Base64 encoding produces roughly 33% larger output than the original rather than hex's 100% larger — Base64 is usually the better choice when size matters and hex readability doesn't.

Limits

Input is capped at 2 MB of text. This tool hex-encodes text input; for encoding an existing binary file, you'd need a file-reading tool rather than a text box.

Frequently asked questions

Is my text uploaded anywhere?
No. Encoding runs entirely in your browser; nothing is sent to a server.
How is text turned into hex?
The text is first encoded as UTF-8 bytes, then each byte (a number from 0 to 255) is written as two hexadecimal digits.
Why is the hex output twice as long as my text?
Every byte becomes exactly two hex characters, so 1 byte of input always produces 2 characters of hex output — before accounting for any multi-byte UTF-8 characters.
What's the difference between the space-separated and compact output?
Both represent the same bytes; space-separated hex is easier to read and matches what hex editors show, while compact hex is easier to paste into code as a single token.