Skip to content
FindTool

    Text to Hex

    Encode text as hexadecimal bytes in the format your tooling expects.

    Text to Hex tool

    Decoding rather than encoding? Use Hex to Text.

    What this tool does

    It shows you the bytes behind your text. Each one becomes two hexadecimal digits, formatted the way the thing you are pasting into expects — spaced for a dump, continuous for a database literal, 0x-prefixed for a C array, \x-prefixed for a Python bytes literal.

    Because hex represents bytes rather than characters, the encoding matters. UTF-8 is the default and gives one byte for ASCII, two for most European accents, three for CJK and four for emoji. Latin-1 gives exactly one byte per character and refuses anything it cannot represent, rather than quietly substituting.

    Common uses

    • Building a test fixture: a byte array for a unit test, or a \x literal for a protocol parser.
    • Writing a binary value into SQL, where MySQL wants X'48656C' and Postgres wants '\x48656c'.
    • Checking exactly which bytes a string occupies before it goes into a fixed-width column or a length-limited header.
    • Confirming that a separator really is a tab and not four spaces, or that a line ends with 0d 0a rather than 0a.
    • Producing a hexdump to compare against one from another machine.

    A short example

    The same six characters in the four formats:

    Input:     Hi! é
    
    Hex:       48 69 21 20 c3 a9
    Binary:    01001000 01101001 00100001 00100000 11000011 10101001
    Decimal:   72 105 33 32 195 169
    Hexdump:   00000000  48 69 21 20 c3 a9    |Hi! ..|

    Five characters, six bytes: é is c3 a9, which is why byte counts and character counts disagree the moment text leaves ASCII.

    Picking a format your tool will accept

    The separator and prefix options are not cosmetic — most consumers accept exactly one shape:

    • Continuous, lowercase — SHA and MD5 digests, git object IDs, colour values.
    • Space-separated — packet dumps, hexdump -C, debugger output.
    • Colon-separated — MAC addresses, certificate fingerprints, OpenSSL output.
    • 0x with commas — C, Go and Rust byte arrays.
    • \x prefixed — Python bytes literals and Postgres bytea.

    Casing is almost always cosmetic; the exception is anything compared as a string, where a lowercase digest will not equal an uppercase one.

    Worth knowing

    Hex doubles the size of your data — two characters per byte, plus separators. That is the price of being readable, and it is why Base64 (four characters per three bytes) is preferred whenever the value only has to survive transport rather than be inspected by a person.

    One thing the byte view makes visible that nothing else does: a byte order mark. A file that starts ef bb bf has a UTF-8 BOM, which is invisible in every editor and will break a strict JSON or CSV parser on the first line.

    Frequently asked questions

    What do the columns and the dots in a hexdump mean?

    The left column is the offset in hexadecimal, sixteen bytes to a line, so 00000010 begins at byte 16. The panel on the right shows those bytes as ASCII, with a dot standing in for anything outside the printable range 0x20–0x7E. A dot is therefore not the character . — a tab, a null byte and the second half of an accented letter all look identical there, which is why the hex column is the one to trust.

    How many bytes will this string take in a database column?

    The byte count here is what byte-limited things measure: an HTTP header, a Kafka key, an index entry. Column limits differ by engine — Postgres varchar(n) counts characters, MySQL VARCHAR(n) counts characters too but the 65,535-byte row limit is in bytes, and the old 767-byte InnoDB index prefix is exactly where the familiar VARCHAR(191) for utf8mb4 comes from.

    Why does code copied from a web page fail to compile?

    The bytes show it at once. A straight double quote is 22, while the curly pair a CMS substitutes are e2 80 9c and e2 80 9d; a hyphen turned into an en dash is e2 80 93; and a space taken from rendered HTML is often c2 a0, a no-break space indistinguishable on screen from 20. Compilers and shells accept none of the substitutes.