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 - The b prefix seen in the earlier byte representation disappears, and the result becomes a standard string: ... $ python decode_bytes.py Bytes: b'<!doctype html><html lang="en"><head><title>Example Domain</title>… String: <!doctype html><html ...
Discussions

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
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 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
🌐
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
September 1, 2024 - 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....
🌐
Vultr
docs.vultr.com › python › examples › convert-bytes-to-a-string
Python Program to Convert Bytes to a String | Vultr Docs
November 27, 2024 - Decode the bytes using utf-8 encoding to handle Unicode characters. ... byte_data = b'\xc2\xa9 2021 Python' string_data = byte_data.decode('utf-8') print(string_data) Explain Code
🌐
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.
🌐
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
Find elsewhere
🌐
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 - 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.
🌐
Mimo
mimo.org › glossary › python › string-decode
Python string decode(): Syntax, Usage, and Examples
Use decode() in Python to convert bytes to readable strings using the correct encoding. It's essential for processing files, APIs, or web content.
🌐
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.
🌐
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
🌐
Codingem
codingem.com › home › python how to convert bytes to string (5 approaches)
Python How to Convert Bytes to String (5 Approaches)
November 28, 2022 - To convert bytes to string in Python, use the bytes.decode() method. For example: b"Alice".decode() returns a string "Alice".
🌐
Stack Abuse
stackabuse.com › convert-bytes-to-string-in-python
Convert Bytes to String in Python
November 27, 2020 - In this tutorial, we'll go over examples of how to convert bytes to a string in Python 2 and 3. We'll use the decode() function, str() function as well as the codecs module.
🌐
Net Informations
net-informations.com › python › iq › byte.htm
How to convert bytes to string in Python?
The most common method for converting bytes to a string in Python is to use the decode() method.
🌐
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 in ... handling requirements. These methods include using the decode() method, the str() constructor, the bytes() constructor, and the codecs module....
🌐
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.
🌐
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 - Using the decode() method, we converted it to a string and stored it in a string_data variable: string_data = byte_data.decode('utf-8'). When you print the characters of the string_data variable, you should get string characters instead of binary ...
🌐
iO Flood
ioflood.com › blog › python-bytes-to-string
Python Bytes to String Conversion Guide (With Examples)
December 11, 2023 - To manage this, you can specify an error handling scheme as a second argument to the decode method, such as ‘ignore’ or ‘replace’. byte_object = b'Hello, Python!\x80' string_object = byte_object.decode('ascii', 'ignore') print(string_object)