Text to Hex
ConvertersConvert text to hexadecimal byte sequences with ASCII or UTF-8 encoding and flexible output formatting (0x prefix, spaces, or continuous).. Free, private — all processing in your browser.
The Text to Hex tool converts any text into its hexadecimal byte representation. Hexadecimal is the compact, readable way to show binary data — each byte as two hex digits (00-FF). Convert \"Hello\" and get 48 65 6C 6C 6F (or 0x48 0x65 0x6C 0x6C 0x6F with prefixes, or 48656C6C6F continuous). Useful for debugging protocols, preparing test data, URL encoding foundations, generating hex literals for code, and any context where you need to see the exact byte sequence produced by a piece of text.
The tool handles ASCII (7-bit English) and UTF-8 (full Unicode, recommended) encoding. Output format is configurable: uppercase vs lowercase hex, with or without 0x prefix per byte, separated by space/comma/dash, or continuous without separators. Each byte is always 2 hex digits with leading zeros preserved for alignment. Unicode characters (emoji, accented letters, CJK) produce multi-byte UTF-8 sequences correctly. Reverse conversion via the companion Hex to Text tool. All processing runs in your browser — safe for sensitive text that shouldn\u2019t leave your machine.
Text to Hex — key features
ASCII and UTF-8
Encodes English-only text compactly in ASCII or full Unicode via UTF-8 multi-byte sequences.
Configurable format
Uppercase or lowercase, with or without 0x prefix, any separator between bytes.
Quick templates
Presets for common formats: C literal, URL, hex dump, network protocol.
Byte count display
Shows character count and byte count so you know the encoding overhead.
Character mapping view
Shows each character alongside its hex representation for clarity.
Copy ready-to-paste
Formatted output copies directly into code, configs, or documents.
Round-trip via companion tool
Verify output by reverse-decoding with the Hex to Text tool.
Client-side only
Input text stays in your browser.
How to use the Text to Hex
- 1
Enter text
Paste any text into the input field.
- 2
Pick encoding
ASCII for English-only, UTF-8 for anything with Unicode (recommended default).
- 3
Choose format
Uppercase or lowercase hex, with or without 0x prefix, with your preferred separator.
- 4
Or pick a template
C literal, URL encoding foundation, hex dump, or network protocol — templates apply correct format.
- 5
Copy output
One-click copy the hex to clipboard, ready to paste.
Common use cases for the Text to Hex
Development
- →Generating hex literals: Produce hex byte arrays for C, Go, or Rust code from source text (e.g., test fixtures or embedded data).
- →URL encoding foundation: Get the hex bytes of text before applying URL percent-encoding.
- →Protocol debugging: See exactly what bytes are produced by specific text in UTF-8 for protocol troubleshooting.
Testing
- →Test fixture preparation: Generate hex representations of text payloads for tests that verify byte-level output.
- →Verification: Check that text-to-byte encoding in application code matches expected hex.
- →Binary test data: Create deterministic hex data for reproducible tests.
Education
- →Teaching character encoding: Show students exactly how UTF-8 represents emoji and accented characters at the byte level.
- →Hex literacy: Familiarize learners with hexadecimal notation via text they recognize.
- →Encoding comparison: Compare ASCII and UTF-8 byte counts for the same text to illustrate encoding overhead.
Text to Hex — examples
Simple ASCII
English word in hex.
Hello
48 65 6C 6C 6F
With 0x prefix
C-style literal format.
Hi
0x48, 0x69
Continuous
No separators — single long string.
Hello
48656C6C6F
UTF-8 accented
Multi-byte sequence for é.
café
63 61 66 C3 A9 (é is 2 bytes: C3 A9)
Emoji
4-byte UTF-8 for grinning face.
Hi 😀
48 69 20 F0 9F 98 80 (😀 is 4 bytes)
Technical details
Text-to-hex encoding steps:
1. Convert the text to a byte sequence using the chosen encoding:
- ASCII: each character\u2019s charCode (0-127) is one byte
- UTF-8: characters encode to 1-4 bytes via standard UTF-8 algorithm
2. For each byte, format as 2-digit hex using toString(16).padStart(2, \"0\")
3. Join bytes with the chosen separator and add any prefix per byte
JavaScript implementation: new TextEncoder().encode(text) returns Uint8Array of UTF-8 bytes. Each byte is then formatted with toString(16) and padded.
UTF-8 multi-byte encoding (automatic with TextEncoder):
- ASCII (0-127): 1 byte, same as ASCII
- 128-2047: 2 bytes (110xxxxx 10xxxxxx)
- 2048-65535: 3 bytes (1110xxxx 10xxxxxx 10xxxxxx)
- 65536+: 4 bytes (11110xxx 10xxxxxx 10xxxxxx 10xxxxxx)
Character count vs byte count: mismatch for UTF-8. \"café\" is 4 characters but 5 bytes (c=1, a=1, f=1, é=2). \"😀\" is 1 character but 4 bytes. The tool reports both.
Common hex output conventions:
- Programming language literal: 0x48, 0x69 (comma + prefix)
- URL encoding foundation: 48 69 (space-separated, no prefix) — actual URL encoding wraps in % signs
- BLOB/binary: 4869 (continuous, no prefix)
- Hex dump: 48 69 across columns with ASCII sidebar
- Network protocol: 48:69 (colon-separated, often lowercase)
The tool offers templates for these common formats plus custom configuration.
Uppercase vs lowercase: most technical contexts use uppercase (48 69) but some code style guides and hashes output lowercase (48 69). Purely cosmetic — both are valid.
Performance: conversion is O(n) and fast. Multi-megabyte text converts in milliseconds.
Size in hex: each byte becomes 2 hex characters. Plain ASCII text doubles in size when represented as hex (plus separators). UTF-8 text with non-ASCII characters may be 2-4x the original text\u2019s byte count due to multi-byte sequences.
Common problems and solutions
⚠ASCII mode fails on non-English
ASCII only handles characters 0-127. Accented letters, emoji, or Asian characters fail in ASCII mode. Use UTF-8 for any non-English content.
⚠Character count ≠ byte count
In UTF-8, one character can be multiple bytes. "é" is 1 character but 2 bytes. Don’t confuse the counts when budgeting buffer sizes.
⚠Case conventions vary
Some systems prefer uppercase hex (48 69), others prefer lowercase (48 69). Both are valid — pick what matches your target system’s convention.
⚠Separator in continuous mode
Continuous hex without separators is compact but harder to read. "48656C6C6F" vs "48 65 6C 6C 6F" — both are the same data. Pick based on where the output is going.
⚠Big-endian byte order
The tool outputs bytes in text order (first character first). This matches UTF-8 and typical hex dump conventions. Don’t reverse bytes thinking of them as numeric values.
⚠Prefix consistency
0x48 0x65 (each with prefix) or 0x4865 (single prefix). The tool offers both — pick what your downstream code expects.
⚠Whitespace characters included
Spaces, newlines, and tabs are real characters with hex values (space = 20, newline = 0A, tab = 09). They appear in the output even when you think of them as "nothing".
Text to Hex — comparisons and alternatives
Compared to a Python one-liner (text.encode().hex()), this tool is faster for one-off use and shows the character-to-byte mapping clearly. For automation, use the language built-in.
Compared to command-line xxd, this tool has a friendlier UI with configurable formats. xxd is ideal for hexdump pipelines; this tool is for interactive hex generation.
Compared to other online text-to-hex tools, this one correctly handles UTF-8 (many assume ASCII only) and provides templates for common use cases (C literals, URL encoding, protocol debugging).
Frequently asked questions about the Text to Hex
▶How do I convert text to hex?
Paste your text and the tool converts each character to its 2-digit hex byte representation. "Hi" becomes 48 69. Pick your encoding (ASCII or UTF-8) and format (separator, prefix, case) in the options.
▶What is the hex of a space character?
The ASCII space character is 0x20 (decimal 32). Every character has a hex value — spaces, tabs (0x09), and newlines (0x0A) are real characters with real hex, not empty space.
▶Why does é take 2 bytes in UTF-8?
UTF-8 encodes accented characters as multi-byte sequences. The codepoint for é is 0x00E9, but UTF-8 cannot fit it in a single byte (which maxes at 0x7F for ASCII compatibility). It encodes as 0xC3 0xA9 — two bytes. This is standard UTF-8 behavior for any character above U+007F.
▶What encoding should I use?
UTF-8 unless you specifically need ASCII-only output. UTF-8 is backward compatible with ASCII (English text produces identical output) and correctly handles any Unicode characters. ASCII mode fails on non-ASCII input.
▶Can I use hex output in C or Go code?
Yes. Pick the C literal template to get output like 0x48, 0x65, 0x6C, 0x6C, 0x6F ready to paste into an initializer. Go, Rust, and other C-derived languages accept the same syntax.
▶What format should I use for URL encoding?
URL percent-encoding wraps each hex byte with %. The tool’s URL template produces space-separated hex; you’d then replace spaces with % (e.g., 48 69 → %48%69). For direct URL encoding, use the URL Encoder tool.
▶Is my text private?
Yes. Encoding runs entirely in your browser. Confidential text — keys, tokens, internal identifiers — never leaves your machine.
▶How do I convert hex back to text?
Use the companion Hex to Text tool. Paste the hex output and it reconstructs the original text. Round-tripping should return identical results.
Additional resources
- ASCII reference — ASCII table with hex values for each character.
- RFC 3629 UTF-8 — Authoritative standard for UTF-8 encoding.
- MDN TextEncoder — Browser API for UTF-8 text encoding used by this tool.
- Wikipedia — Hexadecimal — Background on hex notation.
- Unicode normalization — Reference for consistent Unicode-to-bytes handling.
Related tools
All ConvertersBase64 Encoder/Decoder
Encode and decode Base64 strings, files, and images instantly
Binary to Text Converter
Convert binary code (0s and 1s) to readable text in ASCII or Unicode, with configurable grouping and separator options.
Hex to Text Converter
Convert hexadecimal byte sequences to readable ASCII or UTF-8 text with flexible input formatting.
HTML Entity Encoder/Decoder
Encode special characters to HTML entities (&, <, ", ©) or decode entities back to their literal characters.
Morse Code Translator
Translate between text and Morse code with support for letters, numbers, punctuation, and audio playback of the encoded signal.
Number Base Converter
Convert numbers between binary, octal, decimal, hexadecimal, and any base from 2 to 36 with clear step-by-step output.
Learn more
Explore more tools
200+ free tools that run in your browser.
Browse all tools →