By Tim King · Updated
Text to Hex Converter
Encode a String as Hexadecimal Bytes, With 0x Prefixes and Decoding
OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.
How the Text To Hex Converter works
This text to hex converter works in both directions. Turn text into its hexadecimal bytes and back. Hello becomes 48 65 6c 6c 6f. Pick the
separator, the case, whether to add 0x prefixes, and how many bytes to put on each line for a
readable dump.
How the text to hex converter works
Hexadecimal is how bytes get written down when a person has to look at them. Base 16 needs exactly two digits per byte, so every byte is the same width and the boundaries between bytes are visible at a glance. Base 10 cannot do that, and binary does it at a length nobody can read.
Where hex turns up. Colour codes such as #1e90ff are three bytes of red, green and
blue. MAC addresses are six bytes (3c:22:fb:08:9a:10). IPv6 addresses are sixteen bytes
written as groups of four hex digits. SHA-256 hashes are 32 bytes, so they print as 64 hex
characters, and Git shortens its commit hashes to the first seven. Unicode code points are
quoted as U+00E9. URL encoding writes unsafe bytes as % followed by two hex digits, so a
space becomes %20. Packet captures in Wireshark, memory dumps in a debugger and the
output of xxd or hexdump all use the same layout of bytes in pairs, and every file
format specification lists its magic numbers this way: a PNG starts 89 50 4e 47, a PDF
starts 25 50 44 46, which is %PDF in ASCII.
What is actually being converted. Text is encoded to UTF-8 first, then each byte is
written as two hex digits. For plain ASCII that changes nothing, but it matters for
everything else. é is two bytes, c3 a9; the euro sign is three, e2 82 ac; and most
emoji are four. A converter that used JavaScript's charCodeAt directly would emit UTF-16
code units instead, giving different and usually wrong output for exactly those
characters. Decoding reverses the same path, so a round trip reproduces any input
exactly.
ASCII is the easy half. Every unaccented English letter, digit and common punctuation
mark is a single byte below 0x80, which is why Hello comes out as five tidy pairs:
48 65 6c 6c 6f. Digits run from 30 to 39, so the digit's value is just the second
hex digit. Capital A is 41 and lowercase a is 61. The difference is exactly one bit,
0x20, which is the whole trick behind flipping case with a bitwise operation. Space is
20, line feed is 0a, and a Windows line ending is 0d 0a.
Formatting for reading or for pasting. The options change only the layout, never the bytes.
- Space separators with 8 or 16 bytes per line give the classic hex dump layout. It is the easiest to scan for a pattern or count to an offset, because each line starts at a multiple of 16.
- None gives a continuous string, which is what hex fields in APIs, config files, database blobs and hash comparisons expect.
- Comma with the 0x prefix gives something close to a C, Rust or Python byte array literal, which you can paste into source with minimal editing.
- Case is cosmetic. Lowercase is usual in hashes and Unix tools, while uppercase is common in datasheets and Windows tools. Both decode identically.
How to read the output. In the hex direction, count pairs rather than characters: the
number of pairs is the byte length, which is what a database column limit, a protocol
field or an SMS segment actually counts. Any pair from 80 upwards is part of a multi-byte
character. Pairs from c2 to f4 start a character, and 80 to bf continue one, so you
can see where each character begins. In the text direction, a result containing �
means the bytes were not valid UTF-8. They may be Latin-1, UTF-16 or binary data rather
than text.
Decoding is forgiving. Anything that is not a hex digit is ignored, as are 0x
prefixes. You can paste a dump with spaces, commas, newlines or a mix of all of them and
it will decode. What the tool cannot do is guess a missing digit. An odd number of hex
digits means a byte is incomplete, and you get a message saying so instead of silently
wrong text.
Tips and pitfalls.
- When two strings look identical but compare unequal, convert both. A hex view shows the
culprit immediately: a non-breaking space (
c2 a0), a zero-width space (e2 80 8b), a byte order mark (ef bb bf) at the start, or curly quotes (e2 80 9c) where straight ones (22) were expected. - If you paste a hexdump that still has its offset column, the offsets are hex digits too, and they will be decoded as data. Strip that column and the ASCII column on the right before decoding.
- A hash in hex is not the text of anything. Decoding a SHA-256 digest produces meaningless bytes, because hashing cannot be reversed.
- Hex is a representation, not a cipher. Anyone can decode it in one step, including with this page.
For character-by-character detail, including code points and names, the Unicode inspector goes further. To see the same bytes in other forms, use binary or Base64, which is about a third shorter than hex for the same data.
FAQ
Why does an accented character produce more than two hex digits?
Because the text is encoded as UTF-8 before conversion, and characters outside ASCII take more than
one byte. é is c3 a9 and most emoji are four bytes. That is the correct byte-level
representation.
What does the 0x prefix mean?
It is the conventional marker in C, Python, JavaScript and many other languages that the digits following it are hexadecimal rather than decimal. It is not part of the value — add it when pasting into source, leave it off for raw data.
Can I paste a hex dump with spaces and line breaks?
Yes. When decoding, anything that is not a hex digit is ignored, including spaces, commas, newlines
and 0x prefixes. You can paste a formatted dump straight from a terminal without cleaning it up
first.
Why do I get an error about an odd number of digits?
Because each byte is exactly two hex digits, so an odd count means one digit is missing or one is extra. The tool cannot guess which, so it tells you rather than silently decoding the wrong bytes.
Is converting text to hex a way to hide it?
No. Hexadecimal is a standard, reversible representation with no key involved, and anyone can decode it instantly. It makes text unreadable at a glance and offers no security whatsoever.
See also: all Data & Encoding tools, Dev Utilities, Formatters & Validators, Security & Identifiers, SEO, Accessibility, AI.
Related tools
Base64 Encoder / Decoder
Encode and decode Base64, standard or URL-safe.
Base Converter
Convert numbers between binary, octal, decimal and hex.
ASCII Table
All 128 ASCII codes in decimal, hex, octal and binary.
CRC32 Calculator
CRC-32, CRC-32C and Adler-32 checksums of text or hex bytes.
Hex Dump Viewer
View any file as hex and ASCII, with type detection and entropy.