UTF-8 to Hex Converter

Encodes text using the browser's TextEncoder to produce the true UTF-8 byte sequence (not just each character's Unicode code point), then formats those bytes as space-separated uppercase hex, correctly handling multi-byte characters like accented letters and emoji. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

UTF-8 is the dominant text encoding on the web, but it's a variable-width encoding: each character can take anywhere from 1 to 4 bytes depending on its Unicode code point, which trips up naive "one hex group per character" conversions.

This tool runs your text through the browser's actual UTF-8 encoder before converting to hex, so the output is the exact byte sequence a UTF-8 file, HTTP body, or socket buffer would contain.

What Is UTF-8 to Hex Converter?

A text-to-hex encoder built on the standard `TextEncoder` API, which implements the real UTF-8 encoding algorithm rather than a simplified code-point-to-hex mapping.

It's the UTF-8-correct counterpart to this site's String to Hex Converter, which converts Unicode code points directly and doesn't reflect UTF-8's variable byte width at all.

How UTF-8 to Hex Converter Works

The input string is passed to `new TextEncoder().encode(input)`, which returns a `Uint8Array` of the exact bytes UTF-8 encoding would produce, correctly splitting multi-byte characters into 2, 3, or 4 bytes each per the UTF-8 spec.

Each byte in that array is then formatted as a zero-padded, uppercase 2-digit hex value and joined with single spaces in byte order.

When To Use UTF-8 to Hex Converter

Use it whenever you need the literal bytes a UTF-8-encoded file, HTTP request/response body, or network packet would contain for text that might include non-ASCII characters.

For text you know is strictly ASCII, ASCII to Hex Converter gives identical results with a validation step guaranteeing no other bytes sneak in.

Features

Advantages

  • Produces byte-accurate UTF-8 output using the browser's own standards-compliant encoder, not a hand-rolled approximation.
  • Correctly handles the full Unicode range, including characters outside the Basic Multilingual Plane like most emoji.
  • Matches ASCII to Hex Converter's output exactly for pure ASCII text, so there's no behavior change for the common case.

Limitations

  • Always outputs UTF-8 bytes; if you specifically need UTF-16 or another encoding's byte layout, this isn't the right tool.
  • Doesn't add a byte-order mark (BOM); UTF-8 doesn't require one and most tooling that expects UTF-8 doesn't need it either.

Examples

Encoding an accented character

Input

é

Output

C3 A9

"é" (U+00E9) is outside the 1-byte ASCII range, so UTF-8 encodes it as the 2-byte sequence C3 A9.

Encoding an emoji character

Input

🌍

Output

F0 9F 8C 8D

"🌍" (U+1F30D) is outside the Basic Multilingual Plane, so UTF-8 encodes it as a 4-byte sequence.

Encoding mixed ASCII and multi-byte text

Input

café 🌍

Output

63 61 66 C3 A9 20 F0 9F 8C 8D

The plain ASCII letters and space each take one byte, while "é" takes 2 bytes and "🌍" takes 4, all concatenated in order.

Best Practices & Notes

Best Practices

  • When you need to compare against bytes captured from a real UTF-8 file or network trace, always use this tool rather than a code-point-based hex converter, since only this one matches byte-for-byte.
  • If your output should be pure ASCII and you want that validated, use ASCII to Hex Converter instead so any non-ASCII character is flagged rather than silently multi-byte encoded.

Developer Notes

Implemented as a thin wrapper: `Array.from(new TextEncoder().encode(input), byte => byte.toString(16).padStart(2, "0").toUpperCase()).join(" ")`. All the actual UTF-8 encoding logic is delegated to the browser's built-in `TextEncoder`, which is always UTF-8 per spec (it takes no other encoding argument), so there's no risk of an incorrect hand-rolled encoder.

UTF-8 to Hex Converter Use Cases

  • Reconstructing the exact bytes of a UTF-8-encoded HTTP body or file for debugging or documentation
  • Comparing a hex dump captured from a real system against the expected UTF-8 encoding of some text
  • Teaching or demonstrating how UTF-8's variable-width encoding differs from a fixed one-byte-per-character scheme

Common Mistakes

  • Using a plain code-point-to-hex converter and assuming it matches UTF-8 bytes for non-ASCII text; it only matches for ASCII.
  • Forgetting that a single visible character (like most emoji) can expand to up to 4 hex byte pairs in the output.

Tips

  • If you need to go the other direction, Hex to UTF-8 Converter decodes a UTF-8 hex byte sequence back to text and will catch invalid byte sequences.
  • Compare this tool's output for the same text against String to Hex Converter to see the code-point-vs-byte distinction directly.

References

Frequently Asked Questions