Home Tools Blog About

Convert String to Hex

Convert text to hex (UTF-8) and back with per-character breakdown. 4 separator formats. Free, offline, client-side, instant, secure.

Convert text to hex (and back) using proper UTF-8 encoding - not the broken charCodeAt approach that mangles emoji and accented characters. Per-character grid shows codepoint, byte count, hex, and binary for every input character so multi-byte sequences are visible.

Per-character breakdown

Type to begin.
🛡
100% PrivateNo server uploads, ever
InstantRuns in your browser
💧
No WatermarksClean output, always
🆓
Free ForeverNo accounts, no limits

How to Use Convert String to Hex

  1. Type or paste text. Plain ASCII works, but so does anything Unicode - emoji 😀, accented é, CJK 你好, RTL ‫שלום‬, mathematical ∑. UTF-8 encoding via the browser's standard TextEncoder produces correct multi-byte sequences for every codepoint, unlike older tools that use charCodeAt and produce wrong hex for anything above U+007F.
  2. Choose a separator. Space-separated (48 65 6C 6C 6F) is the most readable, matching standard hex dump format. Comma-separated for CSV-style data. Continuous (no separator) for raw byte strings. 0x-prefixed for pasting into C, Rust, or Python source code as a literal byte array.
  3. Toggle uppercase or lowercase. Default is uppercase (4F) which matches most hex dump conventions and tools like hexdump -C. Lowercase (4f) is common in C and Rust source. Mathematically identical - change to match your destination's style guide.
  4. Read the per-character grid. Each row shows the character, its Unicode codepoint (U+0041), how many UTF-8 bytes it took, the hex, and the binary. Multi-byte characters (≥ 2 bytes) are immediately visible - handy for confirming that é is 2 bytes (C3 A9), not 1.
  5. Swap for reverse. Click ⇄ Swap and direction flips to Hex → Text. The parser accepts any format the tool emits: 48 65 6C 6C 6F, 0x48 0x65, 48656C6C6F, 48,65,6C,6C,6F, mixed whitespace. Strict UTF-8 decoder rejects invalid byte sequences with a specific error rather than silently producing replacement characters.
  6. Batch mode. Multiple lines = TSV table with Input / Hex / Bytes / Chars columns. Download as .tsv and Excel/Sheets parses it into 4 columns. Errors get an ERROR row so one bad line doesn't fail the batch.
  7. Stats summarize. Character count vs byte count tells you instantly whether your text has multi-byte characters. "chars=5 · bytes=5" means pure ASCII; "chars=7 · bytes=11 · multi-byte=2" means there are 2 non-ASCII characters expanding the byte count.

Frequently Asked Questions

Why is this different from other “string to hex” converters?

Many use charCodeAt() which returns UTF-16 code units, not UTF-8 bytes. So é comes out as E9 (looks fine but isn’t UTF-8) and 😀 comes out as D83D DE00 (UTF-16 surrogate pair garbage). This tool uses TextEncoder for real UTF-8: éC3 A9, 😀 → F0 9F 98 80. The output matches what other UTF-8 tools (hexdump, xxd, Python bytes) produce.

Can I convert hex back to text?

Yes – click Swap. The reverse parser is lenient: it accepts any of the four output formats, strips 0x prefixes and commas, normalizes whitespace, then decodes as strict UTF-8. 48 65 6C 6C 6F, 0x48,0x65,0x6C,0x6C,0x6F, and 48656c6c6f all give Hello. Odd-digit input (“must have even digit count”) and non-hex characters get specific errors.

What does strict UTF-8 decoding mean?

The TextDecoder is created with {fatal: true} which throws when bytes don’t form valid UTF-8 – for example a lone continuation byte 80 with no lead byte, or an overlong encoding. Non-strict decoders silently substitute the U+FFFD replacement character ("�") and hide the problem. Strict mode surfaces corruption so you can investigate the source.

Which separator should I use?

Match your destination. Hex dumps and logs: space-separated. CSV imports: comma. Raw byte strings in URLs or DBs: continuous (no separator). C/C++ literal byte arrays: 0x-prefixed like {0x48, 0x65, 0x6C, 0x6C, 0x6F} – paste straight into source code. The output format only affects display; the underlying bytes are identical.

What’s the difference between uppercase and lowercase hex?

None mathematically – 4F and 4f represent the same byte (79 decimal). The choice is stylistic and depends on your tooling. Unix tools like od and xxd default to lowercase. Many Windows tools and macOS Hex Fiend default to uppercase. C/Rust source code conventionally uses lowercase. Pick whichever your codebase uses.

How does it handle emoji and surrogate pairs?

By iterating codepoints (using for…of on the string) rather than UTF-16 chars. JavaScript stores 😀 internally as the surrogate pair 😀 (two 16-bit code units), but for…of yields it as one codepoint (U+1F600) which TextEncoder then encodes as the correct 4-byte UTF-8 sequence F0 9F 98 80. The grid shows it as one row with byte count 4.

What’s the input size limit?

200,000 characters. Beyond that the per-character grid would render too slowly (each row is a DOM node). Hit the cap and you get a clear error pointing to the limit. The grid itself caps at 256 displayed rows with a “… N more characters” note, but conversion still processes the full input – only the grid display is truncated.

Can I use a different encoding like UTF-16 or Latin-1?

No, this tool emits UTF-8 only. UTF-8 is the dominant encoding on the modern web and the natural choice for text-to-hex conversion in 95% of use cases. If you specifically need UTF-16 or windows-1252 hex output (rare), you’ll need a specialized encoder. The reverse direction also only decodes UTF-8 hex.

Is my input uploaded anywhere?

No. All UTF-8 encoding, hex formatting, decoding, and TSV emission run in your browser using standard TextEncoder/TextDecoder. Open DevTools → Network and confirm zero requests fire – even when you Convert or Download. Safe for sensitive text, credentials being audited, or anything you’d rather not send to a third-party converter.

Does it work offline?

Yes. Total bundle is about 18 KB. Load once, disconnect, keep using. The conversion is pure local computation via the standard browser APIs – no fonts to fetch, no analytics, no API. Useful for offline debugging, airgapped environments, or when working on data you don’t want to expose.

Keep going

Related Tools

All Hex tools →