Byte Array to String Converter
ED-30Paste a list of byte values such as [72, 101, 108, 108, 111] to get the text, or paste text to get its bytes. Choose UTF-8, Latin-1 or ASCII and decimal or hex.
Runs in your browser. Nothing is uploaded.
Byte values, or text for the reverse
Result
How to use it
- Paste the byte values, with or without brackets, separated by spaces or commas.
- Pick decimal or hex and the character set the bytes use.
- Click Bytes to string. Use String to bytes to go the other way.
- Copy the result. The Signed and Wrap options only affect String to bytes.
Signed and unsigned bytes
Java bytes are signed, so a UTF-8 character such as é prints as -61 and -87 in an array dump. This tool accepts decimal values from -128 to 255 and treats a negative number as the same byte plus 256, so -61 and 195 mean the same thing. In the other direction, tick the signed option to write values above 127 as negative numbers, the way a Java byte array prints.
Character sets
UTF-8 is the default and reads multi-byte characters such as € or emoji. If a byte cannot start or continue a character, the tool names the position. Latin-1 gives every byte the character with the same number, so it never fails. ASCII allows only 0 to 127. Other sets such as UTF-16, Windows-1252 or Shift JIS are not supported. The same bytes can give different text in each set, so pick the one the data was written in.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
is not a decimal byte | A value is not a whole number or is too long to be a byte. | Use whole numbers from -128 to 255 separated by spaces or commas. |
is outside the byte range | A number is below -128 or above 255. | Check the source; a byte is 0 to 255, or -128 to 127 when signed. |
is not a hex byte | A value in hex mode is not one or two hex digits. | Write bytes as 48 or 0x48. |
is above 127, so it is not ASCII | ASCII was selected but a byte is above 127. | Choose UTF-8 or Latin-1 as the character set. |
Questions people ask
How do I convert a byte array to a string?
Paste the values, for example 72 101 108 108 111 or [72, 101, 108, 108, 111], choose the character set and click Bytes to string. The tool reads the numbers as bytes and decodes them, giving Hello in this case.
What does a negative number in a byte array mean?
It is a signed byte, as printed by Java. Add 256 to get the unsigned value: -1 is 255 and -61 is 195. This tool does that for you when it reads decimal values from -128 to 127.
Which character set should I choose for a byte array?
Use the one the bytes were produced with. UTF-8 is the usual choice for modern text. Latin-1 fits older Western European data. If the output looks garbled, such as é instead of é, try the other set.
Can I turn a string into a byte array?
Yes. Paste the text and click String to bytes. You get the byte values as decimal or hex, in brackets if you leave the wrap option on. UTF-8 text with non-ASCII characters gives more than one byte per character.
Does it work with hex bytes?
Yes. Choose Hex in the format list and write bytes as 48 65 6c 6c 6f or 0x48, 0x65. The same list is used for String to bytes, which then writes 0x-prefixed hex values.
About this tool
Reads numbers separated by spaces, commas or semicolons, with or without [ ], { } or ( ) around them. Decimal values from -128 to 255 are accepted, so a signed Java byte such as -61 is read as 195. Hex values can have a 0x prefix. UTF-8 reads the bytes as one text and reports the first byte that is not valid UTF-8; Latin-1 maps every byte to the character with the same number; ASCII rejects bytes above 127. String to bytes does the reverse and fails on characters that the chosen set cannot hold. UTF-16 and other character sets are not offered.