Hex Encoder/Decoder

Free hex encoder and decoder tool. Convert any UTF-8 text to its hexadecimal representation or decode hex strings back to readable text instantly.

What Hex Encoder/Decoder Does

Takes a plain UTF-8 text string and outputs a continuous lowercase hexadecimal byte sequence where each character is represented as its two-digit hex equivalent. In decode mode, it takes a hex string and reconstructs the original UTF-8 text. The validate function reports whether a hex string is structurally valid and returns its byte length.

Who Uses This Tool

Hex Encoder/Decoder is built for Web developers, security researchers, penetration testers, CTF competitors, network protocol analysts, database engineers inspecting binary fields, backend engineers debugging encoded payloads. Whether you are processing data as part of an automated pipeline or need a quick one-off conversion in your browser, the tool requires no installation and no account — paste your input and get your result in seconds.

Primary Use Case

Encoding a plain text string into its hexadecimal byte representation for use in low-level data inspection, protocol construction, or payload analysis.

The Problem It Solves

Manually converting each character to its hex byte equivalent requires looking up ASCII or UTF-8 tables one character at a time, introducing transcription errors and wasting time on multi-character strings. Multi-byte Unicode characters are especially prone to manual mistakes since they expand to more than two hex digits. This tool handles the full UTF-8 encoding pipeline automatically and validates hex input before decoding to catch malformed sequences before they cause downstream errors.

Example

Input
Hello world
Output
48656c6c6f20776f726c64

When to Use This Tool

Use this tool when analyzing binary payloads, debugging APIs, inspecting encoded data, reverse engineering protocols, handling byte streams, or converting UTF-8 text into hexadecimal format for development and security workflows.

What to Do With the Output

Paste into network packet constructors or protocol buffers, insert into SQL or NoSQL queries inspecting binary columns, use in CTF challenge submissions, embed in security tool payloads, or validate against expected byte sequences in unit tests.

Common Mistakes to Avoid

Hex input with an odd number of characters will be rejected — every byte requires exactly two hex digits, so a string like 48656 is invalid. Spaces and line breaks in hex input are stripped automatically before processing, so formatted hex like 48 65 6c will decode correctly. Entering a hex string in encode mode instead of decode mode produces a double-encoded result — always select the correct operation before submitting. Non-hex characters like g, z, or punctuation in decode input will throw a validation error even if the rest of the string looks valid.

How It Works

Encode mode passes the input string through the browser's native TextEncoder API, which produces a Uint8Array of UTF-8 byte values. Each byte is converted to a two-character lowercase hex string using toString(16) with zero-padding and joined into a single output string. Decode mode first strips whitespace and lowercases the hex input, validates that it contains only 0–9 and a–f characters and has an even character count, then splits it into two-character byte pairs, parses each with parseInt(b, 16), constructs a Uint8Array, and decodes it back to a string using TextDecoder with fatal mode enabled — which throws on invalid UTF-8 sequences rather than silently substituting replacement characters.

Pro Tip

Use the validate function before decoding any hex string received from an external source — it checks both character validity and even-length compliance upfront, giving you byte count alongside the validity result, so you can confirm expected payload size before committing to a full decode operation.

Also Known As

Hex Encoder/Decoder is also commonly referred to as text to hex, hex to text, hex to ASCII, ASCII to hex, UTF-8 hex encoder, hexadecimal string converter, hex dump encoder, byte to hex converter, hex decoder online, string hex converter. All of these terms describe the same conversion — no matter what you call it, this tool handles it.

Frequently Asked Questions

Each byte in hexadecimal requires exactly two digits. A hex string with an odd character count cannot be cleanly split into valid bytes, so the tool rejects it rather than guessing at the intended value.
Yes. The encoder uses the browser's TextEncoder API which produces full UTF-8 byte sequences, meaning multi-byte characters including emoji, accented letters, and CJK characters are encoded correctly across all their constituent bytes.
Whitespace is stripped automatically before decoding, so space-separated or line-broken hex strings are collapsed and processed as a continuous byte sequence.
It confirms that the input contains only valid hexadecimal characters, has an even character count, and returns the total character length and byte count of the string without performing a full decode.
The decoder uses TextDecoder in fatal mode, which throws an error on any invalid UTF-8 byte sequence rather than replacing bad bytes silently. If the hex represents non-UTF-8 binary data, decoding to text will fail by design.
Yes. The swap function moves output back into the input field, allowing you to immediately re-encode a decoded string or run a second operation on the result without manually copying between fields.