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
๐ŸŒ
Real Python
realpython.com โ€บ convert-python-bytes-to-strings
How to Convert Bytes to Strings in Python โ€“ Real Python
November 26, 2025 - In the example above, .decode() uses UTF-8 encoding automatically since no encoding was specified. When the code runs, it converts the raw bytes fetched from the website into a readable HTML string, which can then be displayed or parsed further. The b prefix seen in the earlier byte representation disappears, and the result becomes a standard string: ... $ python decode_bytes.py ...
Discussions

Converting bytes to string to bytes
How can I convert bytes to string to bytes back? Hereโ€™s what Iโ€™m trying: from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import padding message = b"A message I want to sign" signature = private_key.sign( message, padding.PSS( mgf=padding... More on discuss.python.org
๐ŸŒ discuss.python.org
8
0
October 28, 2021
How to convert bytes to string in python?
Try this: line = ser.readline().strip() values = line.decode('ascii').split(',') a, b, c = [int(s) for s in values] The call to .strip() removes the trailing newline. The call .decode('ascii') converts the raw bytes to a string. .split(',') splits the string on commas. Finally the call [int(s) for s in value] is called a list comprehension, and produces a list of integers. More on reddit.com
๐ŸŒ r/Python
3
1
February 8, 2016
How To Convert Bytes To A String - Different Methods Explained
This article confuses more than it explains, I don't consider it very helpful to someone trying to understand the distinction between a character string and a byte string. You may want to look elsewhere for a good explanation. More on reddit.com
๐ŸŒ r/Python
2
0
April 29, 2023
How do I convert a string to bytes?
Or use the bytes() builtin function . An example: x = "abcโ˜บxyz" print(x) y = bytes(x, encoding="utf-8") print(y) More on reddit.com
๐ŸŒ r/learnpython
15
6
August 8, 2023
๐ŸŒ
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 - Note that the decode() method can ... the decoder should expect more input. You can use the str() constructor in Python to convert a byte string (bytes object) to a string object....
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-convert-bytes-to-string-in-python
How to Convert Bytes to String in Python ? - GeeksforGeeks
The str() function of Python returns the string version of the object. ... Itโ€™s a useful alternative, especially when you're not calling it on a byte object directly. The codecs module provides an alternative way to decode bytes, especially useful when dealing with different encodings.
Published ย  July 23, 2025
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ library โ€บ stdtypes.html
Built-in Types โ€” Python 3.14.5rc1 documentation
Otherwise, the bytes object underlying ... bytes.decode(). See Binary Sequence Types โ€” bytes, bytearray, memoryview and Buffer Protocol for information on buffer objects. Passing a bytes object to str() without the encoding or errors arguments falls under the first case of returning the informal string representation ...
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
Converting bytes to string to bytes - Python Help - Discussions on Python.org
October 28, 2021 - How can I convert bytes to string to bytes back? Hereโ€™s what Iโ€™m trying: from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import padding message = b"A message I want to sign" signature = private_key.sign( message, padding.PSS( mgf=padding.MGF1(hashes.SHA256()), salt_length=padding.PSS.MAX_LENGTH ), hashes.SHA256() ) converting the signature using base64 encode and decode methods to string.
Find elsewhere
๐ŸŒ
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.
๐ŸŒ
Vultr
docs.vultr.com โ€บ python โ€บ examples โ€บ convert-bytes-to-a-string
Python Program to Convert Bytes to a String | Vultr Docs
November 27, 2024 - byte_data = b'Hello, Python!' string_data = byte_data.decode('utf-8') print(string_data) Explain Code
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ string-decode
Python string decode(): Syntax, Usage, and Examples
The decode() method in Python is used to convert byte data into a Unicode string. In Python 3, strings are Unicode by default, so decode() applies specifically to bytes objects.
๐ŸŒ
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.
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ python-string-encode-decode
Python String Encode and Decode: Complete Guide | DigitalOcean
August 3, 2022 - Python string encode() function is used to encode the string using the provided encoding. This function returns the bytes object. If we donโ€™t provide encoding, โ€œutf-8โ€ encoding is used as default. Python bytes decode() function is used to convert bytes to string object.
๐ŸŒ
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 - How do you convert bytes to string? A. You can convert bytes to a string using .decode('utf-8') in Python, which decodes the byte object into a human-readable string using UTF-8 encoding.
๐ŸŒ
FavTutor
favtutor.com โ€บ blogs โ€บ bytes-to-string-python
4 Methods to Convert Bytes to String in Python (with code)
February 8, 2023 - The decode() function in python can be used to take our data encoded in bytes format and decode it to convert the data to string format.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ byte to string python
Byte to String Python - Scaler Topics
January 16, 2024 - We'll examine an illustration of how to decode a given byte stream using the codecs.decode() function. ... The map() method in python accepts a function and a Python iterable object (list, tuple, string, etc.) as inputs and returns a map object.
๐ŸŒ
Flexiple
flexiple.com โ€บ python โ€บ bytes-to-string
Python Bytes to String โ€“ How to Convert a Bytestring - Flexiple
February 23, 2024 - To convert bytes to a string, Python uses the decode method. This method applies a specific encoding to transform bytes into a string.
๐ŸŒ
WsCube Tech
wscubetech.com โ€บ resources โ€บ python โ€บ programs โ€บ bytes-to-string
Convert Bytes to a String in Python (5 Programs)
October 29, 2025 - Learn to convert bytes to a string in Python with 5 simple programs. Clear examples and outputs make it easy to understand.
๐ŸŒ
JanBask Training
janbasktraining.com โ€บ community โ€บ python-python โ€บ convert-bytes-to-a-string-in-python-3
Convert bytes to a string in Python 3 | JanBask Training Community
May 25, 2025 - Use .decode('encoding') to convert bytes to string. UTF-8 is the most common and default encoding. If you're not sure what encoding to use, try 'utf-8' first. If the bytes contain characters not compatible with the chosen encoding, Python will ...