If you want to convert bytes to string in Python, then you may use multiple ways of doing that. In this article, we are going to look at few methods.

Consider this example –

bytes_string = b'Ironman'


In this code, I am using decode function with utf-8 encoding to convert bytes of Ironman back to string.

Another way of doing that is using str() function with encoding. Check this code –

bytes_string = b'Ironman'

print(str(bytes_string, encoding))

If you have array of bytes then you may first convert them into characters and then join them together to make a string. Look at this code example –

>>> bytes_string = [73, 114, 111, 110, 109, 97, 110]
>>> print("".join(map(chr, bytes_data)))

    Tweet this to help others

Live Demo

Demo might not work in private window (incognito)


About the Author


I am Akash Mittal, an overall computer scientist. If you want to guest post, need help in your projects, want to advertise, Feel free to contact me at [email protected]

View All Articles