Byte to string decoding
Debuggers and logs often print binary data as a list of numbers: [72, 101, 108, 108, 111]. The byte to string converter reads those numbers as bytes and decodes them as UTF-8 text, so you can see the message hidden in the array.
Accepted input
- Decimal values from 0 to 255.
- Negative values from −128 to −1, as printed by Java, Kotlin or C#
sbyte; they are converted by adding 256. - Hex values when Decode notation is set to Hex, or individual values written with
0x. - Separators: spaces, commas, semicolons and line breaks. Brackets, braces and parentheses are ignored, so array literals from most languages paste straight in.
Example
Input:
[72, 101, 108, 108, 111, 32, -61, -87, 116, -61, -87]Output:
Hello étéThe pairs -61, -87 are the signed form of 195, 169 — the UTF-8 bytes of “é”.
Where byte arrays come from
- Java’s
Arrays.toString(bytes)and Kotlin’scontentToString(). - Node.js
BufferandUint8Arrayoutput in the console. - Python
list(b"...")output, or bytes stored as JSON arrays by an API. - Serial monitors and embedded debug output for microcontrollers.
If you are unsure whether a list holds bytes or code points, look at the range: values above 255 can only be code points, while negative values can only be signed bytes. A list with many values between 128 and 255 in pairs or triples is almost always UTF-8.
Decoding bytes in code
Java: new String(bytes, StandardCharsets.UTF_8). C#: Encoding.UTF8.GetString(bytes). Python: bytes([72, 105]).decode("utf-8") (negative values must first be converted with b % 256). JavaScript: new TextDecoder().decode(new Uint8Array([72, 105])). Always name the character set explicitly: platform defaults vary and are a classic cause of garbled text.
Troubleshooting
- “Byte values must be between -128 and 255”. A value is out of range, which usually means the numbers are Unicode code points rather than bytes. Use ASCII to Text for code points.
- Replacement characters (�). The bytes are not valid UTF-8 — they may be binary data, or text in another encoding.
- Wrong characters in hex mode. Make sure the notation matches the input; “10” is sixteen in hex but ten in decimal.
Convert text into bytes with String to Byte Array, or decode Unicode code points with ASCII to Text. Everything runs in your browser.
Convert bytes to string in Python
In Python a bytes object becomes text with .decode("utf-8"). The classic mistake is calling str() on it, which returns the representation b'Hello \xc3\xa9t\xc3\xa9' rather than the text. For a list of numbers, wrap it in bytes() first; values must be 0 to 255, so signed bytes copied from Java raise ValueError until you apply % 256. Add errors="replace" when the data may not be valid UTF-8, otherwise decode() raises UnicodeDecodeError.
data = b"Hello \xc3\xa9t\xc3\xa9"
print(str(data)) # the repr, not the text
print(data.decode("utf-8")) # Hello été
# a list of numbers, including signed Java bytes
values = [72, 101, 108, 108, 111, 32, -61, -87, 116, -61, -87]
text = bytes(value % 256 for value in values).decode("utf-8")
print(text)
# bytes that are not valid UTF-8
print(b"caf\xe9".decode("utf-8", errors="replace"))
The converter above decodes the same signed list to the same text, a quick way to confirm what an array holds before you write the byte to string code.