Convert a String to Bytes online for free
What is String to Bytes?
String to Bytes is a free online tool that converts any text string into its hexadecimal byte representation using UTF-8 encoding. It’s an essential utility for developers working with low-level data processing, network protocols, or debugging encoding issues.
Unlike simple ASCII converters, this tool correctly handles Multi-byte characters (like Chinese, Emojis, and special symbols) by generating the standard UTF-8 byte sequence.
Need to decode hex bytes back to text? Use our Bytes to String Converter.
How to use
- Enter Text: Type or paste your string into the input box.
- View Result: The hexadecimal byte sequence appears instantly in the output box.
- Customize Format: Use the options to match your specific needs:
- Use Full Bytes: Pads single-digit hex values with a leading zero (e.g.,
Abecomes0A). - Add Delimiter: Separates bytes with spaces for better readability.
- Uppercase Output: Converts hex digits to uppercase (e.g.,
ffbecomesFF). - Byte Prefix: Adds a custom prefix like
0xor\xto each byte (useful for programming arrays).
- Use Full Bytes: Pads single-digit hex values with a leading zero (e.g.,
Examples
| Input String | Settings | Output Result |
|---|---|---|
Hello | Default | 48 65 6c 6c 6f |
Hello | Uppercase | 48 65 6C 6C 6F |
ABC | Prefix: 0x, Comma (manual) | 0x41 0x42 0x43 |
你好 | Default (UTF-8) | e4 bd a0 e5 a5 bd |
✨ | Default | e2 9c a8 |
Why use String to Bytes?
1. Protocol Analysis
When debugging network packets or binary file formats, you often need to see the exact byte sequence of a string. Example: Verify what bytes are actually sent when you transmit “Login”.
2. Programming Setup
Quickly generate byte arrays for C, Python, or Java.
Example: Convert “Error” to 0x45, 0x72, 0x72, 0x6f, 0x72 for a C array.
3. Encoding Debugging
Understand how different characters are stored in memory. Example: See the difference between ASCII characters (1 byte) and Emoji (4 bytes).
4. Python Compatibility
Generate hex strings compatible with Python’s bytes.fromhex() or string literals.
How it works
This tool utilizes the browser’s built-in TextEncoder API to perform standard UTF-8 encoding. This ensures 100% compatibility with modern web standards and programming languages. It takes the code points of your input characters and converts them into the corresponding 8-bit sequences defined by the Unicode standard.
FAQ
Is this compatible with Python?
Yes! If you set the Use Full Bytes option and remove delimiters, the output 48656c6c6f can be used directly in Python:
bytes.fromhex("48656c6c6f") # b'Hello'
Or use the Byte Prefix \x to create a string literal: b'\x48\x65\x6c\x6c\x6f'.
Does it support Chinese or Emojis?
Yes, it fully supports all Unicode characters via UTF-8 encoding. Characters like ‘你’ will be converted to e4 bd a0.
What is the maximum length?
The tool runs entirely in your browser, so the limit depends on your device’s memory. modifying or analyzing large text blocks is fast and secure—no data is sent to any server.