Hexadecimal represents each eight-bit byte with exactly two base-16 digits, 0-9 and a-f. This encoder operates on UTF-8 or uploaded bytes and emits lowercase pairs; the decoder removes whitespace and reads pairs back into bytes.
Use hex to inspect byte streams, hashes, protocol fields, or file signatures because byte boundaries remain obvious. It doubles raw size, an odd number of digits is invalid, and it provides no compression, encryption, or integrity by itself.
# Encoding
printf 'Hello' | xxd -p
# Output: 48656c6c6f
# Decoding
printf '48656c6c6f' | xxd -r -p
# Output: Hello
// Encoding
let encoded = Buffer.from("Hello").toString("hex");
console.log(encoded);
// Output: 48656c6c6f
// Decoding
let decoded = Buffer.from("48656c6c6f", "hex").toString();
console.log(decoded);
// Output: Hello
package main
import (
"encoding/hex"
"fmt"
)
func main() {
// Encoding
encoded := hex.EncodeToString([]byte("Hello"))
fmt.Println(encoded)
// Output: 48656c6c6f
// Decoding
decoded, _ := hex.DecodeString("48656c6c6f")
fmt.Println(string(decoded))
// Output: Hello
}
// Encoding
$encoded = bin2hex("Hello");
echo $encoded . "\n";
// Output: 48656c6c6f
// Decoding
$decoded = hex2bin("48656c6c6f");
echo $decoded . "\n";
// Output: Hello