Text Tools

String to Hex

Encode text into a hex string for transport, debugging, and inspection.

Start here Paste the exact text, including any trailing spaces or newlines you want to inspect.

Hex output

456e636f6465207468697320646576656c6f706572206e6f74652e

Understand the format

How String to Hex works

Hexadecimal shows the exact bytes behind a piece of text, which is the only reliable way to see invisible characters and encoding differences.

Two hex digits per byte

Text is converted to bytes with UTF-8, and each byte is printed as exactly two hexadecimal digits, from 00 to ff. ASCII characters occupy one byte each, so "Hi" becomes 4869. Characters outside ASCII take two to four bytes: the euro sign is e2 82 ac, and most emoji are four bytes.

Because the mapping is fixed at two digits per byte, the length of the hex string is always double the byte count. That gives you a quick integrity check: an odd number of hex characters means the value was truncated somewhere.

Why byte-level inspection settles arguments

Two strings that look identical on screen can differ in bytes. A non-breaking space (c2 a0) renders exactly like an ordinary space (20). A carriage return (0d) is invisible until it breaks a comparison. A zero-width space contributes bytes while occupying no visual width at all.

This is why hex output is the standard tool for diagnosing "but they are the same string" bugs in signature verification, checksum mismatches, and failing equality checks. The bytes cannot hide what the rendering does.

Step by step

How to use String to Hex

  1. Paste the exact text, including any trailing spaces or newlines you want to inspect.
  2. Read the hex output, working in pairs of digits, where each pair is one byte.
  3. Compare against the expected bytes, or against the hex of a known-good value.
  4. Look for 0d 0a line endings, c2 a0 non-breaking spaces, and a trailing 0a when a comparison unexpectedly fails.

Conversion uses the browser TextEncoder in the page, so the text you inspect is never uploaded.

Worked examples

String to Hex examples explained

Plain ASCII

Input

Hi

Result

4869

Capital H is 0x48 and lowercase i is 0x69, matching the ASCII table exactly.

An invisible trailing newline

Input

OK followed by a line break

Result

4f4b0a

The 0a is a line feed. This single byte is the most common reason a copied value fails to match a stored one.

Reference

Byte values worth recognising on sight

Byte values worth recognising on sight
BytesCharacterNote
20SpaceThe ordinary ASCII space.
09TabOften introduced by copying from a table.
0aLine feedThe Unix line ending.
0d 0aCarriage return and line feedThe Windows line ending, and the cause of many diff and hash mismatches.
c2 a0Non-breaking spaceLooks like a space, compares as a different character. Common when copying from web pages.
ef bb bfByte-order markAn invisible prefix that breaks strict JSON and CSV parsers.
e2 82 acEuro signA reminder that one character is not always one byte.

Practical Guide

How teams use String to Hex

Common use cases

  • Inspect how text will be represented in systems that store or transmit hexadecimal.
  • Prepare values for low-level protocol tests and fixtures.
  • Compare two strings when invisible characters or spacing may be involved.

Checks before trusting the result

  • The output depends on the character encoding, so compare like with like.
  • Invisible characters such as line breaks change the result and are exactly what you are looking for.
  • Keep the plain-text copy alongside the hex so a reviewer can validate the source.

Troubleshooting

Common mistakes and how to fix them

Comparing this output with hex produced from a UTF-16 source.
The byte sequences will differ for every character. Confirm both sides use UTF-8 before concluding the data is wrong.
Assuming one character equals one byte when calculating lengths.
Only for ASCII. Database column limits expressed in bytes will reject shorter strings that contain multi-byte characters.
Pasting text from a rich-text editor and getting unexpected bytes.
Editors substitute typographic quotes, en dashes, and non-breaking spaces. Paste through a plain-text step first.

FAQ

String to Hex questions, answered

Why is the hex string always an even length?

Every byte is printed as two digits, padded with a leading zero when needed. An odd length means characters were lost.

Is hexadecimal a form of encryption?

No. It is a printable representation of bytes and is trivially reversible, exactly like Base64 but 100% larger instead of 33%.

Why does one character produce several byte pairs?

UTF-8 is a variable-length encoding. ASCII takes one byte, most European and Middle Eastern scripts two, most CJK characters three, and emoji four.

Should the output be uppercase or lowercase?

Either is valid and they represent the same bytes. This tool emits lowercase, which is the more common convention in HTTP headers and Unix tooling.

How do I get the hex of a binary file?

Use a tool that reads the file bytes directly, such as xxd or a hex editor. Pasting binary content as text corrupts it before the conversion starts.

Go deeper

Specifications and guides