The essential text to hex rule is simple: encode the text as UTF-8, then represent each byte with exactly two hexadecimal digits.

That rule keeps the result tied to actual bytes rather than visual character count. It matters because one character can occupy several bytes, while formatting options such as spaces and 0x prefixes can make the output longer without changing a single encoded byte.

text to hex tips and common mistakes
Text to Hex Tips and Common Mistakes

Choose the Layout Before You Encode

Start with the requirements of the program that will consume the result. The converter presents the same UTF-8 byte array as continuous pairs, space-separated pairs, or space-separated 0xNN tokens. These are presentation choices, not different encodings. In the spaced and prefixed layouts, no delimiter appears before the first token or after the last.

LayoutExampleOutput code units for n bytesPractical fit
Continuous48692nCompact output when the receiver accepts uninterrupted pairs
Space-separated48 693n − 1Manual inspection or a receiver that expects separated pairs
0x-prefixed0x48 0x695n − 1Code or logs that explicitly expect per-byte 0x tokens

In the table’s two-byte example, the source text is Hi and its UTF-8 bytes are 48 69. With n = 2, plain length is 2n = 2 × 2 = 4; spaced length is 3n − 1 = 3 × 2 − 1 = 5; prefixed length is 5n − 1 = 5 × 2 − 1 = 9. The encoded bytes never changed; only their presentation did.

Uppercase mode changes only the letters A through F. It does not change byte values, and the 0x marker remains lowercase. Keep leading zeros because every byte requires two digits. Choose the syntax required by the destination rather than the format that merely looks easiest to read.

Encode Text in the Browser

  1. Open the converter and enter the source. Use Text To HEX and paste the exact text into the browser field, including Unicode characters, whitespace, and NUL data that the field can hold. Empty input is rejected. Encoding and clipboard preparation run locally in the current browser tab; the input and output are not uploaded.
  2. Choose the output syntax. Select continuous, space-separated, or 0x-prefixed output, then choose lowercase or uppercase hexadecimal digits. Match these choices to the format expected by the destination.
  3. Encode the text. The complete input is converted to UTF-8 bytes before formatting is applied, so the result is not assembled from a shortened sample.
  4. Review the result. Check the UTF-8 byte count, formatted output length, and replacement count. A nonzero replacement count means at least one isolated UTF-16 surrogate was standardized to U+FFFD, so that output is not an exact representation of the original code units.
  5. Copy the complete output. If clipboard access is denied, manually select the complete read-only result. Editing the input or changing an option clears the earlier output, so copy the result before making another change.

Separate UTF-8 Bytes from Character Numbers

One visible character does not necessarily mean one byte. ASCII characters occupy one UTF-8 byte, many common Latin characters occupy two, most characters in the Basic Multilingual Plane occupy three, and supplementary Unicode scalars occupy four. A byte always becomes two hexadecimal digits, so a multi-byte character spans multiple pairs.

The browser conversion uses the TextEncoder API. The MDN TextEncoder.encode documentation describes its byte output, while the WHATWG Encoding Standard defines the conversion. This is UTF-8 byte encoding, not a conversion to UTF-16 code units, Windows-1252, a locale code page, or an ASCII-only fallback.

A frequent mistake is to treat a Unicode code-point number as if it were the stored byte. A code point identifies a character; UTF-8 chooses one or more bytes to represent that character. Hex output must follow the byte choice, not the visible glyph or the number of visible characters.

Preserve Whitespace, Control Data, and Combining Marks

Whitespace is data. Spaces, tabs, CR, and LF remain in their supplied order, and NUL U+0000 becomes byte 00. The converter does not trim edges, convert line endings to a different convention, or treat NUL as a terminator. Text that looks nearly identical can therefore produce different bytes when a space, tab, or line ending is missing.

The converter also does not apply Unicode normalization. A decomposed combining sequence remains decomposed unless the source was already composed. It performs no case folding, escape-sequence parsing, or locale-aware rewriting. If the destination expects precomposed characters or normalized line endings, normalize the source deliberately before encoding rather than assuming the hex conversion did it.

Distinguish an Added BOM from a BOM Character

TextEncoder does not prepend a UTF-8 byte order mark. Ordinary input begins directly with the first character’s bytes. If the source itself contains U+FEFF, that character is encoded as data, producing EF BB BF; the encoder did not add it as metadata.

An internal U+FEFF remains part of the text as well. Do not remove the opening bytes merely because they resemble a BOM unless the destination intentionally requires the actual leading U+FEFF to be omitted. Keeping this distinction prevents a valid source character from being changed without explanation.

Interpret Surrogate Replacement Warnings Before Reusing Output

Browser text is represented by JavaScript strings, which use UTF-16. A valid high-plus-low surrogate pair represents one supplementary Unicode scalar and is encoded normally. An isolated high or low surrogate is not a Unicode scalar. Standard TextEncoder conversion replaces each isolated code unit with U+FFFD, whose UTF-8 bytes are EF BF BD.

The result panel counts these replacements and displays a warning. Decoding EF BF BD can restore the replacement character, but it cannot reconstruct the original isolated surrogate, so the operation is not reversible. Use the count as a quality check before relying on the output for an exact round trip, and correct the source so it contains well-formed Unicode.

Plan for Delimiter Overhead and Output Limits

The converter has two independent budgets: input may contain at most 1,000,000 UTF-16 code units, and formatted output may contain at most 4,999,999 UTF-16 code units. One code unit over either limit is rejected with an explicit message. The exact output boundary is accepted: 1,000,000 ASCII characters in 0x-prefixed format produce exactly 4,999,999 output code units.

Delimiter and prefix overhead matters because the output budget counts the formatted result, not only the encoded bytes. Plain output is 2n code units, spaced output is 3n − 1, and 0x-prefixed output is 5n − 1 for n bytes. Multi-byte Unicode in a verbose format can therefore reach the output limit before the input limit.

The complete text is encoded and the required size is checked before the large output string is built. The converter reports overflow instead of switching formats, slicing bytes, dropping a suffix, or sampling content. If the task exceeds a limit, split the source at meaningful application boundaries and track the pieces separately; the converter will not perform that split for you. The bulk UTF-8 encoding guide provides more guidance for planning large jobs.

Verify the Bytes and Catch Common Errors

Use a decoder for verification when a round trip matters. The Hex to Text converter uses documented TextDecoder BOM behavior. Copy the complete result into it. Under that behavior, it consumes a leading EF BB BF, so an exact round trip through that specific decoder requires that the original text not begin with U+FEFF. An internal U+FEFF is not affected by that leading-only rule.

Hexadecimal is a readable representation of bytes, not encryption, hashing, compression, or secret protection. Anyone with the bytes and the UTF-8 rules can recover well-formed text. The browser converter does not upload input or output, but local processing should not be confused with secrecy.

Before copying, run this final check:

  • The chosen layout and letter case match the receiver’s requirements.
  • Every byte appears as exactly two digits, with leading zeros intact.
  • The byte and replacement counts match what the task expects.
  • Spaces, tabs, line endings, and NUL data are present in the intended order.
  • Any U+FEFF was retained because it was source data, not mistaken for encoder metadata.
  • The output is complete and was not copied from a stale result.
  • The result was checked against the input and formatted-output budgets.
  • The hex is being used for encoding or debugging, not treated as a secret.

Related reading: XOR Encryption Online on Mac: Repeat-Key Text Workflow.