Skip to content

Convert ASCII to hex

Turn ASCII characters into their hex byte values with configurable spacing, case and prefix — and a warning for anything outside ASCII.

  • Runs in your browser
  • Nothing you enter is sent
  • Free, no account
ASCII text → Hex
Conversion runs as you type. Use Swap to send the result back into the input and reverse the direction.

The converted value appears here.

Options

One byte per character, 0-255. Anything above U+00FF is rejected rather than mangled.

Applies to the generated output. Input is parsed with or without separators.

Dump a file
Drop a binary file to see its bytes. Large files are truncated to the first 512 KB.
Drop a file hereRead locally with the File API — nothing is uploaded.Any file · up to 64 MB each

One character, one byte, two hex digits

In ASCII mode each character produces exactly one byte, so the output length is always twice the input length. Anything above U+00FF cannot fit in a byte and is reported with a clear message naming the character, rather than being silently replaced with a question mark — which is what most converters do and what makes their output impossible to trust.

Worked example

Input:   Hex OK!
Chars:   H    e    x    ␣    O    K    !
Decimal: 72   101  120  32   79   75   33
Hex:     48   65   78   20   4F   4B   21

Notice the space. It is a real character with the code 0x20, and forgetting it is the usual reason a hand-counted byte total comes out short.

Uppercase or lowercase

No parser cares. Conventions differ by field: RFCs, hardware datasheets and Windows tooling lean uppercase; Unix tools, most programming languages and web APIs lean lowercase. Git, OpenSSL and sha256sum all print lowercase. Match whatever you are comparing against, because a diff tool does care.

Where a hex string is expected

ContextExpected shape
C or Rust byte array0x48, 0x65, 0x78
Shell printf\x48\x65\x78
Modbus / serial protocol frameContinuous uppercase, no separators
MySQL literalX'486578'
URL percent-encoding%48%65%78 — uppercase by convention

Sending text to a device

The most common real use of ASCII-to-hex is building a frame for a serial or TCP device that documents its commands as hex. Two details bite every time. First, line terminators are part of the command: many devices expect a trailing 0D, 0A or 0D 0A, and the documentation often writes it as <CR>. Second, a checksum is usually computed over the bytes you just generated, not over the text — so generate the hex first, then checksum it.

Why not just use Base64?

Hex doubles the size; Base64 adds only a third. Hex wins anyway when a human has to read the result, when you need to point at byte number seven, or when the receiving system is a piece of hardware whose documentation is written in hex. Base64 wins when the payload is large and nobody will ever look at it.

Questions

What happens to characters that are not ASCII?

In ASCII/Latin-1 mode anything above U+00FF is rejected with a message naming the offending character, rather than being silently mangled. Switch to UTF-8 to encode it properly as multiple bytes.

Does it encode spaces and line breaks?

Yes. Space is 20, line feed is 0A and carriage return is 0D. Windows line endings therefore appear as the pair 0D 0A, which is often exactly the detail you are hunting for.

Uppercase or lowercase hex — does it matter?

Not to any parser. Uppercase is the convention in protocol specifications and hardware documentation, lowercase in most programming languages and web tooling. The toggle is purely cosmetic.

Why does my "identical" string produce different hex?

Almost always an invisible difference: a non-breaking space (C2 A0 in UTF-8) instead of 20, a smart quote instead of a straight one, or a trailing newline. The hex view is the fastest way to find it.