UTF-8 byte accurateHex dump viewStrict decode errors

Text to Hex Converter

Convert text to hexadecimal UTF-8 bytes and back, with separator and 0x prefix options, a hex dump view, and a per-character byte breakdown. All processing happens locally in your browser.

Byte-level hex

Convert text to hexadecimal bytes and back

This page works on bytes: text is encoded as UTF-8 first, then each byte is written as two hex digits. For converting a single number between bases, use the Number Base Converter instead.

Input characters
UTF-8 bytes
Hex digits
Bytes per character
Output formatting
InputText
OutputHex bytes

Hex bytes appear here as you type.

Encoding uses TextEncoder, so one character can produce one to four bytes.

Load sampleLoad text to encode

What is hexadecimal, and what does this page convert?

Hexadecimal is base 16. It uses sixteen digits: 0 1 2 3 4 5 6 7 8 9 A B C D E F, where A is 10 and F is 15.

It is popular for one specific reason: a byte holds a value from 0 to 255, and that range fits exactly into two hex digits. 00 is the lowest byte, FF is the highest. One byte is always two hex digits, with no leftover, which makes hex the natural shorthand for raw data.

Scope of this page: it converts text and bytes. Text is encoded to UTF-8 first, then written as hex pairs. If you want to convert a single number between bases — say decimal 255 to FF, or binary 1010 to A — use the Number Base Converter, which is built for arithmetic values rather than byte streams.

How to convert text to hex bytes

  1. Pick a direction Text → Hex encodes what you type. Hex → Text decodes pairs of digits back into characters.
  2. Set the output format Choose the separator (space, none, colon, comma, or one byte per line), whether digits are uppercase, and whether each byte carries a 0x prefix. Different tools expect different shapes.
  3. Read the stats row Character count, byte count, hex digit count and average bytes per character update as you type. When bytes exceed characters, the input contains non-ASCII text.
  4. Optionally open the hex dump The dump shows offset, hex bytes and printable ASCII side by side, 16 bytes per row — the same layout as xxd or hexdump -C.

Examples: bytes are not code points

This is the detail that trips up most hex tools. A character's Unicode code point and its UTF-8 bytes are different numbers.

Character Code point UTF-8 bytes (hex) Bytes used
A U+0041 41 1
é U+00E9 C3 A9 2
U+20AC E2 82 AC 3
U+65E5 E6 97 A5 3
🙂 U+1F642 F0 9F 99 82 4

Notice é: the code point is E9, but the UTF-8 encoding is C3 A9. A converter that simply prints the code point in hex would output E9 and produce a byte stream no UTF-8 reader can decode. This page encodes real bytes, and the per-character table below the editors shows both numbers so the difference is visible.

A full word, encoded:

Input:  café
Output: 63 61 66 c3 a9

c=63  a=61  f=66  é=c3 a9   → 4 characters, 5 bytes

Byte notation you will see in the wild

The same five bytes get written many different ways depending on the tool that produced them:

Style Looks like Where it comes from
Space separated 63 61 66 c3 a9 Hex dumps, packet captures, documentation
Continuous 636166c3a9 Hashes, database BLOB literals, checksums
Colon separated 63:61:66:c3:a9 MAC addresses, TLS certificate fingerprints
0x prefixed 0x63 0x61 0x66 C, C++, Rust, Go, assembly source
Escape sequences \x63\x61\x66 Python, PHP, shell strings, JavaScript

The 0x prefix is not part of the value. It is a marker telling a compiler or reader "the digits that follow are base 16", exactly as 0b means binary. When decoding, this tool strips 0x and \x prefixes along with spaces, commas, colons, semicolons, dashes and pipes, so you can paste any of the shapes above without cleaning it up first.

Common mistakes when decoding hex

  • An odd number of digits. 4a5 cannot be split into bytes. Almost always a leading zero was dropped: 4a 05, not 4a5. The error message says how many digits were found so you can spot where the pair is missing.
  • Single-digit tokens. 4a 5 6c is ambiguous — is 5 the byte 05 or the start of 56? Rather than guess, the decoder asks you to write it as 05.
  • Bytes that are not text. Compressed data, a JPEG, or an encryption key will not decode to readable characters. Strict UTF-8 decoding reports the failure instead of filling your output with replacement characters, and a lossy fallback is shown separately so you can still inspect it.
  • Confusing hex with Base64. Both turn binary into printable text, but hex uses 16 characters and doubles the size, while Base64 uses 64 characters and adds about a third. If your string contains letters past F, or + and /, it is Base64 — use the Base64 Encoder & Decoder.
  • Assuming ASCII. Byte C3 on its own is not a character. It is the first half of a two-byte sequence. Tools that decode byte-by-byte with Latin-1 turn café into café, which is the classic mojibake signature.

Use cases for byte-level hex

  • Identifying a file from its header. Paste the first bytes of an unknown file: 89 50 4E 47 is PNG, FF D8 FF is JPEG, 25 50 44 46 is PDF, 50 4B 03 04 is ZIP.
  • Debugging encoding bugs. When text arrives garbled, converting both the expected and received strings to hex shows exactly which bytes changed.
  • Reading protocol traces. Serial, Modbus, MQTT and BLE logs are hex. Decoding a payload section reveals embedded ASCII fields.
  • Writing byte literals. Turn a string into 0x-prefixed bytes to paste into firmware or a test fixture.
  • Checking invisible characters. A zero-width space is E2 80 8B and a non-breaking space is C2 A0. Both look like nothing in an editor but appear plainly in hex.
  • Verifying database BLOB values. MySQL and PostgreSQL print binary columns as continuous hex; decoding shows whether the stored value is what you expect.

Privacy and how conversion runs

Encoding uses the browser's TextEncoder and decoding uses TextDecoder in strict mode. Both run in the page, so your text is not uploaded to convert it.

Note: hex is a representation, not protection. 70 61 73 73 77 6f 72 64 is trivially readable as password. Never treat hex-encoded data as hidden.

Frequently Asked Questions

Why is my byte count higher than my character count?

Because UTF-8 uses a variable number of bytes per character: 1 for ASCII, 2 for most accented Latin and Cyrillic letters, 3 for CJK and most symbols, and 4 for emoji and rarer scripts. The per-character table under the editors shows the exact split for your input.

What is the difference between this and the Number Base Converter?

This page treats input as a stream of bytes: "255" becomes 32 35 35, the three ASCII characters. The Number Base Converter treats it as the number 255 and returns FF. Same digits, completely different question.

Can I paste hex copied from a hex editor or Wireshark?

Yes. Spaces, newlines, commas, colons, semicolons, dashes, pipes, 0x prefixes and \x escapes are all stripped before decoding, so most copied dumps work directly. Offset columns and ASCII sidebars are not stripped, so remove those first.

Should hex digits be uppercase or lowercase?

They are equivalent — 4A and 4a are the same byte. Conventions differ by ecosystem: RFCs and certificate fingerprints usually favour uppercase, while Unix tools, Git hashes and most programming languages output lowercase. The toggle covers both.

What does the hex dump ASCII column show?

Each byte in the printable ASCII range (0x20 to 0x7E) is shown as its character; everything else becomes a dot. It is a quick way to spot readable strings such as file magic numbers or embedded metadata inside otherwise binary data.

Why did strict decoding fail when the bytes look fine?

Strict UTF-8 rejects incomplete multi-byte sequences. If a copied dump was cut mid-character — for example ending on C3 with no following byte — the sequence is invalid even though every individual pair is valid hex. The lossy fallback shows the result with U+FFFD marking each problem byte.