Decode the bytes object to produce a string:

>>> b"abcde".decode("utf-8")
'abcde'

The above example assumes that the bytes object is in UTF-8, because it is a common encoding. However, you should use the encoding your data is actually in!

Answer from Aaron Maenpaa on Stack Overflow
🌐
DataCamp
datacamp.com › tutorial › bytes-to-string-python
How to Convert Bytes to String in Python | DataCamp
June 12, 2024 - To convert bytes to strings in Python, we can use the decode() method, specifying the appropriate encoding.
🌐
freeCodeCamp
freecodecamp.org › news › python-bytes-to-string-how-to-convert-a-bytestring
Python Bytes to String – How to Convert a Bytestring
April 10, 2023 - In this example, we define a byte string b"Hello, world!" and use the str() constructor to convert it to a string object. We specify the encoding format as utf-8 using the encoding parameter.
Discussions

Convert bytes to a string in Python 3 - Stack Overflow
If you want to convert byte array to string cutting off trailing '\x00' characters the following answer is not enough. Use b'example\x00\x00'.decode('utf-8').strip('\x00') then. 2013-04-16T13:27:01.373Z+00:00 ... Official documentation for this: for all bytes and bytearray operations (methods which can be called on these objects), see here: docs.python... More on stackoverflow.com
🌐 stackoverflow.com
How to concatenate byte strings in Python 3
Python 3.5 will re-introduce some restricted %-formatting, for bytestrings. With Python 3 and the split between str and bytes , one small but important area of programming became slightly more difficult, and much more painful -- wire format protocols https://www.python.org/dev/peps/pep-0461/ More on reddit.com
🌐 r/Python
7
0
February 28, 2015
How can I convert the HTTP_Reponse to a usable string or bytes?
That response instance that you're trying to decode is the whole http response, that includes status code, headers, body and a bunch of other stuff. What your want to decode is the body of the response I think, so look into the attributes of the HTTPResponse object, maybe you can use something like response.read() Edit: found the method More on reddit.com
🌐 r/Python
4
1
October 22, 2019
How to interpret Python's b string literal?
This isn't a hex literal, it's ASCII, like a normal C string. b"hello world" is also entirely valid. If you want the raw byte 0x86, that would be written b"\x86". More on reddit.com
🌐 r/learnpython
4
1
December 14, 2022
🌐
Real Python
realpython.com › convert-python-bytes-to-strings
How to Convert Bytes to Strings in Python – Real Python
July 18, 2026 - This process involves converting raw bytes from step one into a readable string. In Python, the bytes.decode() method handles this task. It’s a built-in method that belongs to every bytes object and returns a string representation of the data. In this practical example, you continue from the previous step by modifying decode_bytes.py:
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-convert-bytes-to-string-in-python
How to Convert Bytes to String in Python ? - GeeksforGeeks
The codecs module provides an alternative way to decode bytes, especially useful when dealing with different encodings. ... If you have a list of ASCII values, you can manually convert them into characters and join them into a string. ... Each ASCII value is converted into its character using chr(). Then characters are then joined into a complete string using .join() method. In this example, we are importing a pandas library, and we will take the input dataset and apply the decode() function.
Published: July 23, 2025
🌐
freeCodeCamp
freecodecamp.org › news › python-bytes-to-string-code-examples
Python Bytes to String – How to Convert a Str to Bytes and Back Again
April 16, 2024 - When you print the characters of the string_data variable, you should get string characters instead of binary values: print(string_data[0]) # H · In this article, you learned how to use bytes in Python.
🌐
w3resource
w3resource.com › python › python-bytes.php
Python Bytes, Bytearray
Bytes objects can be constructed the constructor, bytes(), and from literals; use a b prefix with normal string syntax: b'python'. To construct byte arrays, use the bytearray() function.
Find elsewhere
🌐
Programiz
programiz.com › python-programming › examples › bytes-to-string
Python Program to Convert Bytes to a String
To understand this example, you should have the knowledge of the following Python programming topics: ... Using decode(), you can convert bytes into string. Here, we have used utf-8 for decoding.
🌐
iO Flood
ioflood.com › blog › python-bytes-to-string
Python Bytes to String Conversion Guide (With Examples)
December 11, 2023 - For instance, b'Hello, Python!'.decode() would return 'Hello, Python!'. For more advanced methods, background, tips, and tricks, continue reading the rest of the article. ... Let’s begin by explaining the process of converting bytes in Python. Here’s another example to illustrate the process ...
🌐
KDnuggets
kdnuggets.com › convert-bytes-to-string-in-python-a-tutorial-for-beginners
Convert Bytes to String in Python: A Tutorial for Beginners - KDnuggets
July 15, 2024 - Use the str() constructor to convert a valid bytes object to a string. Use the decode() function from the codecs module that is built into the Python standard library to convert a valid bytes object to a string.
🌐
Analytics Vidhya
analyticsvidhya.com › home › 3 ways to convert bytes to string in python
3 Ways to Convert Bytes to String in Python
March 26, 2025 - The decode() method is the most straightforward way to convert bytes to a string in Python. It takes an encoding parameter, which specifies the encoding to be used. Here’s an example of how to use the decode() method:
🌐
Stack Abuse
stackabuse.com › convert-bytes-to-string-in-python
Convert Bytes to String in Python
November 27, 2020 - For example, if we tried using the str() function with UTF-16, we'd be greeted with: >>> str(b, 'UTF-16') '敌❴\u2073牧扡愠\uf020趟↕' This is even more important given that Python 3 likes to assume Unicode - so if you are working with files or data sources that use an obscure encoding, ...
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python convert bytes to string
Python Convert Bytes to String - Spark By {Examples}
May 31, 2024 - You can convert bytes to strings very easily in Python by using the decode() or str() function. Bytes and strings are two data types and they play a
🌐
Vultr
docs.vultr.com › python › examples › convert-bytes-to-a-string
Python Program to Convert Bytes to a String | Vultr Docs
November 27, 2024 - In this snippet, byte_data is a bytes object encoded in 'utf-8'. The decode() method converts these bytes into a string. The result would display "Hello, Python!". Include byte data with non-ASCII characters.
🌐
Programiz
programiz.com › python-programming › methods › built-in › bytes
Python bytes()
The source parameter can be used to initialize the byte array in the following ways: The bytes() method returns a bytes object of the given size and initialization values. string = "Python is interesting." # string with encoding 'utf-8'
🌐
Net Informations
net-informations.com › python › iq › byte.htm
How to convert bytes to string in Python?
convert bytes to string in Python convert string to bytes in Python , We can convert bytes to String using bytes class decode() instance method, So you need to decode the bytes object to produce a string.
🌐
Real Python
realpython.com › python-bytes
Bytes Objects: Handling Binary Data in Python – Real Python
March 5, 2025 - A RESP request is an array of bulk strings, with the first—and sometimes the second—element representing a Redis command, followed by any optional arguments. Here are some examples: Knowing these details allows you to implement the following helper functions for constructing such messages in Python: ... def array(*items): binary = bytearray(f"*{len(items)}\r\n".encode("ascii")) for item in items: binary.extend(item) return bytes(binary) def bulk_string(value): binary = value.encode("utf-8") return f"${len(binary)}\r\n".encode("utf-8") + binary + b"\r\n"
🌐
Board Infinity
boardinfinity.com › blog › bytes-to-string-in-python
Bytes to String in Python | Board Infinity
July 11, 2023 - The str () function may be used to transform the bytes to regular strings as well. The simple software needed to comprehend this approach is provided below. ... As Python programmers, we frequently encounter errors related to bytes when working on various languages.
🌐
PyTutorial
pytutorial.com › convert-bytes-to-string-in-python-guide
PyTutorial | Convert Bytes to String in Python | Guide
February 8, 2026 - Converting bytes to strings is common in real-world applications. Let's look at a few scenarios. When you open a file in binary mode ('rb'), you get bytes. Decoding is necessary to work with the text. # Reading and decoding a text file with open('example.txt', 'rb') as file: byte_content = file.read() # This is bytes string_content = byte_content.decode('utf-8') # Convert to string print(string_content[:100]) # Print first 100 characters
🌐
Delft Stack
delftstack.com › home › howto › python › how to convert bytes to string in python 2 and python 3
How to Convert Bytes to String in Python 2 and Python 3 | Delft Stack
February 2, 2024 - You could see from the time performance shown above, decode() is much faster, and chr() is relatively inefficient because it needs to reconstruct the string from the single string character. We recommend using decode in the performance-critical application. bytes in Python 2.7 is identical to str; therefore, the variable initiated as bytes is the string intrinsically.