Home/Dev Tools/Text to Hex Converter

Text to Hex Converter

Convert

Convert plain text to hexadecimal representation for encoding and debugging.

Mode
Format
Case
Input
Loading editor…
Output
Loading editor…
✨ AI Code Explanation
Mode

What Is Hexadecimal Encoding?

Hexadecimal (hex) is a base-16 numbering system using digits 0–9 and letters A–F. In computing, hex is commonly used to represent binary data in a compact, human-readable form. Each byte (8 bits) is represented as exactly two hex digits — for example, the ASCII letter H is 48, and a space is 20. Hex encoding is widely used in debugging, network protocols, cryptography, and file format analysis.

How Text → Hex Conversion Works

  • Each character in the input is encoded to bytes using UTF-8 via the browser's TextEncoder API.
  • ASCII characters (A–Z, a–z, 0–9, common punctuation) produce exactly one byte each.
  • Non-ASCII characters (accented letters, CJK, emoji) produce 2–4 bytes each — the hex output will be longer than the character count.
  • Each byte is converted to a two-digit hex number (e.g. byte 7248).
  • The separator, case, and 0x prefix options control how the hex bytes are joined.

How Hex → Text Conversion Works

  • Input is normalised: 0x prefixes, colons, commas, and spaces are stripped.
  • The remaining string is split into 2-character hex pairs.
  • Each pair is parsed as an integer (base 16) to produce a byte value.
  • The byte sequence is decoded as a UTF-8 string via TextDecoder, recovering the original text.

Separator Formats and 0x Prefix

  • SP (space)48 65 6c 6c 6f — Most readable. Standard in network dumps and xxd output.
  • : (colon)48:65:6c:6c:6f — Common in MAC addresses, TLS certificate fingerprints, and OpenSSL output.
  • ∅ (none)48656c6c6f — Compact. Used for embedding hex strings in source code or JSON.
  • 0x prefix0x48 0x65 0x6c — Standard notation in C, C++, and assembly. Works with any separator.
  • Uppercase / Lowercase4865 vs 4865 — Both are valid hex; use uppercase for display, lowercase for most code contexts.

What Is UTF-8 and Why Does It Matter Here?

UTF-8 is a variable-width character encoding that represents every Unicode code point. ASCII characters use 1 byte, Latin/European accented characters use 2 bytes, CJK characters use 3 bytes, and emoji use 4 bytes. This tool uses UTF-8 for both directions — so the byte count shown may exceed the character count when non-ASCII text is encoded. For example, the emoji 🌍 encodes to 4 bytes: f0 9f 8c 8d.

Common Use Cases

  • Network debugging — Inspecting raw packet payloads in Wireshark or tcpdump hex dumps.
  • File signatures (magic bytes) — PDF files start with 25 50 44 46 (i.e., %PDF); PNG files start with 89 50 4e 47.
  • Cryptographic output — Hash digests and encryption keys are typically expressed as hex strings.
  • Source code — Embedding binary constants in C (0x48, 0x65) or Python (\x48\x65).
  • TLS / SSL certificates — Certificate fingerprints and serial numbers use colon-separated hex.
  • Data encoding — When binary data must be transported as a text-safe string without Base64.

Hex Quick Reference Table

CharHexCharHexCharHex
Space20A41a61
030B42b62
131C43c63
939Z5az7a
\n (LF)0a\r (CR)0d\t (Tab)09

Related Tools