ASCII to Hexadecimal Converter

Raw hex, 0x byte array & \x escapes · Instant byte count · 100% client-side

Presets:
ASCII / Text Input 0 chars
Hexadecimal Bytes
0 chars

      
Ready
Ctrl+Enter Convert · 100% Local
Advertisement
Reserved fixed-height slot (CLS = 0.00) 728×90 320×100 300×50

Formatting ASCII Strings as Hexadecimal Literals for Systems Work

Converting ASCII to hex is essential when authoring BPF packet filters, SQL UNHEX() queries, embedded C lookup tables, or binary protocol test fixtures. Each ASCII byte expands cleanly to two hexadecimal digits, so a 20-byte ASCII header always yields exactly 40 hex characters.

Watch out for line-ending differences when pasting multi-line text: Unix systems use LF (0x0A) while HTTP/1.1, SMTP, and Windows text files use CRLF (0x0D 0x0A). Inspecting the exact hex output reveals hidden whitespace, trailing newlines, or curly smart quotes that break strict parsers.

  • Output StylesSpace-separated (47 45 54), contiguous (474554), C array (0x47, 0x45), and \x47\x45 literals.
  • ASCII ValidationFlags characters outside 0x00–0x7F and encodes them accurately as UTF-8 hex bytes.
  • Zero PaddingAlways pads single-nibble control bytes (0x00–0x0F) to two hex digits (e.g., 0A for LF).
What is the hex code for a space, newline, and carriage return?

Space is 0x20, Line Feed (\n) is 0x0A, Carriage Return (\r) is 0x0D, and Horizontal Tab (\t) is 0x09.

How do I use the hex output inside a C or Rust byte slice?

Select the 0x comma-separated format (e.g., 0x47, 0x45, 0x54) and paste it directly inside uint8_t buf[] = { ... }; or let buf: &[u8] = &[...];.

What happens if my input contains non-ASCII Unicode characters?

Characters above U+007F are encoded into their multi-byte UTF-8 hex sequence and flagged so you know the buffer is no longer pure 7-bit ASCII.