Skip to content

Hex Converter

Updated: 7 comments

Convert text to hexadecimal values or turn space-separated hex codes back into text. Enter your content and choose To HEX or To Text.

Text to Hexadecimal Converter

Input Fields
If enabled, the result will update automatically when you change any value.

Hex Converter Formula

Formula
\[h_i=\operatorname{pad}_{2}\!\left(\operatorname{base}_{16}(u_i)\right),\qquad u_i=\operatorname{parse}_{16}(h_i)\]

Where:

  • \(u_i\) — a UTF-16 code unit of the input text.
  • \(h_i\) — its lowercase hexadecimal representation, padded to at least two digits.

To HEX converts each UTF-16 code unit separately and joins the values with spaces. To Text parses each whitespace-separated hexadecimal value and converts it to a UTF-16 code unit.

Hex Converter – Calculation Example

Example: enter Hi in Content and select To HEX.

\[\texttt{H}\rightarrow 72_{10}=48_{16},\qquad \texttt{i}\rightarrow 105_{10}=69_{16}\]

Result: 48 69. To reverse it, enter 48 69 and select To Text; the result is Hi.

How to use the Hex Converter

  1. Enter text or hexadecimal values in the Content field. The field accepts multiple lines, although whitespace at the beginning and end is removed before conversion.
  2. Choose To HEX from the Type menu to convert text into hex values. This is the default selection.
  3. Choose To Text to decode hex values. Separate values with spaces, tabs, or line breaks; for example, enter 48 69 rather than 4869 to produce Hi.
  4. Read or copy the converted value under Result. If Content is empty after surrounding whitespace is removed, the calculator asks you to enter content.

What does a hex conversion represent?

Hexadecimal, or base 16, writes numbers using the digits 0–9 and the letters a–f. Each hex digit represents four bits, so hex is a compact way to display numeric values. This calculator turns text into a readable sequence of those values and can turn the sequence back into text. The spaces in a To HEX result separate values; they are not part of the original text unless an internal space was itself converted.

For basic Latin letters, digits, and punctuation, the result looks like familiar ASCII hex: A becomes 41, and an internal space becomes 20. This makes the result useful when inspecting character values or checking a short text sequence. If you want decimal character numbers instead, use the ASCII Converter; for sequences written in base 2, see the Binary Converter.

The conversion works on the UTF-16 code units used by JavaScript, not on UTF-8 bytes. A character outside the basic multilingual plane, such as many emoji, is represented by two code units and therefore produces two space-separated hex values. The result should not be treated as a UTF-8 hex dump or as a file’s raw bytes. If you need to represent data for transport rather than inspect these character values, Base64 Encoder uses a different encoding method.

Input rules and practical limits

In To HEX mode, each code unit produces a lowercase hex value with a minimum width of two digits. Values above ff can therefore have three or four digits. The values are separated by single spaces in the result; the converter does not add a 0x prefix. Copy the complete result, including its separators, if you plan to decode it with To Text.

In To Text mode, whitespace separates values, not pairs of digits. For example, 48 69 is read as two values, while 4869 is read as one hexadecimal number and produces a different character. Enter hexadecimal values rather than a continuous byte stream, and check unexpected output for missing separators or invalid values.

The calculator removes leading and trailing whitespace from Content before either conversion. As a result, it cannot preserve spaces or line breaks at the very start or end of the text you enter. Whitespace inside the text is retained in To HEX mode and converted into its own hex values. These details matter when you are comparing an output with an exact original string: test a short sample first, then verify that converting it back gives the text you expect.

Frequently Asked Questions

How can I convert a character to hex by hand?

Find the character’s numeric value, then divide it by 16. The remainder is the last hex digit; repeat with the quotient until it reaches zero, then read the remainders backward. For example, B has the value 66: dividing by 16 gives 4 remainder 2, so its hex value is 42. This works directly for basic Latin characters.

Why does this result differ from a UTF-8 hex converter?

The two tools represent different things. This converter shows UTF-16 code units, while a UTF-8 hex converter shows encoded bytes. For example, é appears here as e9, but its UTF-8 bytes are c3 a9. Neither result is wrong; choose the byte-based converter when you need to inspect a file, network message, or UTF-8 encoding.

Why does one emoji produce two hex values?

Many emoji have Unicode code points above the range of a single UTF-16 code unit. UTF-16 represents each of these characters with a pair called surrogates. For example, 😀 produces d83d de00. Keep both values in order when decoding; either value alone does not represent the emoji and may display as a replacement symbol.

Can I use uppercase hex or a 0x prefix when decoding?

Uppercase letters work: 4A and 4a decode to the same value. A 0x prefix, as in 0x4a, is also accepted by the underlying hexadecimal parser, though the converter does not add prefixes to its own results. Keep each character value as a separate whitespace-delimited item. Do not use commas as separators.

What happens if a hex value is invalid or too large?

The decoder does not strictly validate each item. A value such as 41xyz may still decode as A because parsing stops at the first non-hex character. An item with no valid hex digits can become an invisible null character, while a value above ffff is reduced to a UTF-16 code unit. Check input carefully if an exact result matters.

Is converting text to hex a way to encrypt it?

No. Hex is a readable representation of numeric values, not encryption. Anyone can convert the values back without a key, so hex does not protect passwords, private messages, or other sensitive data. If you need confidentiality, use an established encryption method; if you only need to inspect character values, hex is appropriate.

Leave a Reply

Your email address will not be published. Required fields are marked *

7 thoughts on “Hex Converter”