Convert text, ASCII, and strings to hexadecimal and back

How text-to-hex conversion works, why the encoding setting matters, how to decode hex back to readable text, and when plain text is the better choice.

Converting text to hexadecimal rewrites each byte of the text as two characters drawn from 0–9 and A–F. The word "Hi" becomes 48 69, and decoding 48 69 gives back "Hi". This review explains what the conversion changes, when it suits the job, and what happens when hex output is copied, shared or decoded.

Short verdict: is hex conversion right for your use?

Hex is a good fit when you need to see or move the exact bytes behind a piece of text. Typical cases are debugging encoding problems, spotting invisible characters, comparing strings that look identical but don't match, and preparing values for code, protocols, test fixtures or specifications. Its main benefit is a lossless, unambiguous view of the data. Its decisive tradeoff is that people can no longer read it. Hex also at least doubles the length of the text, and it only decodes correctly if both ends use the same character encoding. Use plain text whenever a person needs to read, search, edit, translate or hear the content.

What the conversion actually changes

Computers store text as bytes according to a character encoding such as UTF-8. A hex converter takes those bytes and writes each one as a two-digit base-16 number. The output is a new string made of different characters. It is not a font, a visual effect or a styling layer. Decoding reverses the process exactly, as long as the same encoding is used in both directions.

Character | Unicode code point | UTF-8 bytes in hex
A | U+0041 | 41
a | U+0061 | 61
space | U+0020 | 20
0 (digit) | U+0030 | 30
! | U+0021 | 21
é (single code point) | U+00E9 | C3 A9
€ | U+20AC | E2 82 AC
😀 | U+1F600 | F0 9F 98 80

In the ASCII range (00–7F), the byte value and the code point are the same. So "Hello" becomes 48 65 6C 6C 6F whether a tool labels its mode ASCII, UTF-8 or Latin-1. Outside that range, the result depends on the encoding.

The encoding setting decides the result

The same character can produce different hex in different encodings. The letter é is C3 A9 in UTF-8, E9 in ISO-8859-1 or Windows-1252, and 00 E9 in big-endian UTF-16. The euro sign is E2 82 AC in UTF-8 and 80 in Windows-1252, and it does not exist in ISO-8859-1 at all. If a converter doesn't say which encoding it uses, don't trust its output for non-ASCII text. To check a tool quickly, convert é, € and 😀 and compare the results with the table above. UTF-8 is the usual choice for new work.

Text that looks the same can be stored differently. An é can be a single code point, U+00E9 (C3 A9 in UTF-8), or a plain e followed by a combining acute accent, U+0301 (65 CC 81). Hex makes this difference visible, which helps when two strings refuse to match. It also means two visually identical strings can produce different hex. Many emoji are sequences of several code points, such as skin-tone modifiers or zero-width-joiner combinations, and each code point takes several bytes. If you split or truncate hex, cut only at character boundaries. Cutting in the middle of a sequence leaves invalid bytes.

Code points, bytes and the many hex notations

"The hex code for a letter" can mean two different things: its Unicode code point (U+1F600 for 😀) or its encoded bytes (F0 9F 98 80 in UTF-8). Both are legitimate, but they are not interchangeable. Hex also appears in several notations:

  • 48 65 6C 6C 6F: space-separated bytes, the most common converter output
  • 48656C6C6F: a continuous hex string with no separators
  • 0x48 0x65 0x6C: a per-byte prefix used in many programming languages
  • \x48\x65\x6C: escape sequences inside string literals in C, Python and similar languages
  • %48%65%6C: percent-encoding as used in URLs, normally applied only to reserved or non-ASCII bytes
  • H: an HTML numeric character reference, which holds a code point rather than a byte, so 😀 is 😀
  • U+0048: standard Unicode code point notation

Converting a hex string to hex usually means switching between these notations. It can also signal a common mistake: encoding text that is already hex. The characters "48" encode to 34 38. If your decoded output turns out to be another run of hex digits, the data was probably encoded twice.

A few related terms are often confused with text-to-hex conversion. Hex color codes such as #FF0000 describe red, green and blue values, not text. There is no "hex font", and hex conversion does not reverse, mirror or restyle letters. Puzzle sites sometimes call hex a cipher, but it is an encoding with no key, so anyone can decode it. Hex hides nothing and protects nothing.

Decoding hex back to ASCII or readable text

Decoding reads the digits in pairs, turns each pair into a byte, and interprets the bytes with an encoding. Most failures fall into one of these patterns:

  • Odd number of digits, or characters outside 0–9 and A–F (other than separators the tool accepts): the input is incomplete or not hex.
  • Bytes from 80 to FF when decoding as ASCII: ASCII only defines 00–7F. The tool has to do something with these bytes, such as raise an error, insert a replacement character or silently apply a legacy code page.
  • Invalid UTF-8 sequences: many decoders substitute U+FFFD, the replacement character often drawn as a question mark in a diamond, and the original byte is lost.
  • Wrong encoding selected: the output becomes garbled. For example, C3 A9 decoded as Windows-1252 shows "é" instead of é.
  • Control bytes such as 00 (null), 09 (tab), 0A (line feed) and 0D (carriage return): these decode to invisible characters that may be dropped or may change the layout.
  • Prefixes and separators: tools differ on whether they accept or strip 0x, \x or commas, so check before pasting mixed formats.

Readability and usability after copying or sharing

Hex output contains only digits, the letters A–F and optional separators, all plain ASCII. That character set makes it less likely to be altered in transit than raw Unicode text, which is a real advantage for moving exact bytes through chat, email or form fields. The remaining risks are mostly formatting: line wrapping that inserts breaks, and separators being added or removed. Hex digits are case-insensitive when decoded, but systems that compare strings literally will treat 6c and 6C as different. These points follow from the character set. No specific app or destination was tested, so check the one you rely on.

For accessibility, the words are not available to readers or assistive technology. A screen reader has nothing to announce except digits and letters, because the hex itself carries no words. No specific screen reader was tested for this review. Search works the same way: search tools index the hex characters, not the decoded words, so a search for "Hello" will not find 48656C6C6F. Editing means decoding, changing the text and re-encoding. Hand-editing hex risks creating invalid sequences.

Length grows predictably. Each byte becomes two characters before separators are added. ASCII text therefore at least doubles, a UTF-8 é becomes four hex digits, and a single-code-point emoji becomes eight. Fields with character limits may truncate the result, and a cut at an odd position breaks the final byte.

Always provide a plain-text equivalent for human-facing content, such as posts, messages, labels, alt text and documents, and for anything that must be searchable or translatable. Hex belongs in logs, test data, specifications and debugging notes, where exact bytes matter. When you share it, label it with its encoding, for example "UTF-8 hex".

Converting locally instead of online

Converting on your own machine keeps the text off third-party services and makes the encoding explicit. The examples below use UTF-8.

# Python 3.8+
text = "Hello"
hex_str = text.encode("utf-8").hex(" ")         # '48 65 6c 6c 6f'
back = bytes.fromhex(hex_str).decode("utf-8")   # 'Hello'
// Browser or Node.js
const bytes = new TextEncoder().encode("Hello");
const hex = Array.from(bytes, b => b.toString(16).padStart(2, "0")).join(" ");
// "48 65 6c 6c 6f"
const back = new TextDecoder().decode(
  Uint8Array.from(hex.split(" "), h => parseInt(h, 16))
);
// "Hello"
printf 'Hello' | xxd -p          # 48656c6c6f
echo '48656c6c6f' | xxd -r -p    # Hello

In the shell, echo appends a newline, so echo 'Hello' | xxd -p produces 48656c6c6f0a. The trailing 0a is that newline. Use printf when the exact bytes matter. The xxd utility usually ships with Vim and may not be installed on every system.

What to check in an online hex converter

No specific online converter was evaluated for this review. If you use one, check these points:

  • It states which encoding it uses, and ideally lets you choose.
  • It converts é, € and 😀 to the byte values in the table above.
  • It offers the separator and prefix format your destination expects.
  • It reports invalid input instead of silently inserting replacement characters.
  • A round trip, text to hex and back, reproduces your input exactly, including line breaks.

A converter's appearance or marketing claims don't tell you how it handles the text you paste. Unless you have confirmed its data handling, keep passwords, keys and personal information out of web tools, and use the local methods above for anything sensitive.

Limits of this review

The byte values and code examples here reflect documented encoding and language behavior. The statements about copying, search and accessibility are based on the character set and decoding mechanics, not on tests in specific apps, platforms or screen readers. Before you depend on hex output in a particular destination, test a round trip there.