Hex to String Converter

Encode text to hexadecimal or decode a hex string back to readable ASCII/UTF-8 text — paste and convert instantly.

Usage:
  • String to hex: Paste content on left, click 'Hex Encode';
  • Hex to string: Paste encoded content on right, click 'Hex Decode';

What is Hex Encoding

Hex (hexadecimal) encoding splits each byte (8 bits) into a high nibble and a low nibble, each mapped to one character of 0-9 and A-F, so one byte is always represented by exactly two hex characters. The output is twice the original size, but contains only printable characters, making it easy to store and transmit binary data in logs, config files and URLs.

Note the difference between hex encoding and a hexadecimal number: the former turns any byte sequence into readable text, while the latter (e.g. 0xFF) is just a numeric notation — the 0x prefix is not part of the encoded content.

How Encoding & Decoding Works

  • Encoding: for each byte, look up the high 4 bits and low 4 bits in 0123456789ABCDEF and concatenate the two characters.
  • Decoding: every two characters are converted back into one byte, so a hex string must have an even length or decoding fails.
  • For example, byte 0xD6 (binary 11010110): the high nibble 1101 maps to D and the low nibble 0110 maps to 6, giving D6.

Conversion Examples

InputHex
Hello48656c6c6f
中 (UTF-8)e4b8ad
newline \n0a

ASCII characters are encoded byte by byte. Non-ASCII characters (e.g. Chinese) are first encoded as multiple UTF-8 bytes — a common Chinese character takes 3 bytes — then each byte becomes two hex characters.

Go

import "encoding/hex"

hex.EncodeToString([]byte("Hello")) // "48656c6c6f"
hex.DecodeString("48656c6c6f")      // []byte("Hello")

Python

"Hello".encode("utf-8").hex()         # '48656c6c6f'
bytes.fromhex("48656c6c6f").decode()  # 'Hello'

JavaScript

// encode
Array.from(new TextEncoder().encode("Hello"))
    .map(b => b.toString(16).padStart(2, "0")).join("") // "48656c6c6f"
// decode
new TextDecoder().decode(
    new Uint8Array("48656c6c6f".match(/../g).map(h => parseInt(h, 16)))
) // "Hello"

Java

import java.util.HexFormat;

HexFormat.of().formatHex("Hello".getBytes()) // "48656c6c6f"
HexFormat.of().parseHex("48656c6c6f")        // byte[] "Hello"

Use Cases

  • Network protocol and serial port debugging: inspect raw packet bytes as readable text;
  • Log and packet-capture analysis: turn invisible binary content into printable, searchable form;
  • Hash and key display: MD5, SHA digests and keys are usually shown in hex.

Related tools: Base64 Encoder/Decoder, URL Encoder/Decoder

FAQ

Why does decoding fail with a length error?
Two hex characters map to one byte, so the input must have an even length. Check for a missing or extra character, or stray spaces and 0x prefixes.
Can I decode hex with a 0x prefix?
No. 0x is a literal prefix used by programming languages and is not part of the encoded content — remove it before decoding.
Hex vs Base64 — what's the difference?
Both convert binary to printable characters. Hex expands one byte to two characters (2× size) with an obvious byte-by-byte mapping; Base64 is about 1.33× and better for large payloads.
Why does Chinese text get so long in hex?
Non-ASCII characters are first UTF-8 encoded into multiple bytes (3 bytes for a common Chinese character), and each byte becomes two hex characters — so one character typically becomes six.

Try it out

68747470733a2f2f7777772e637965616d2e636f6d2f

Feedback