Decode the bytes object to produce a string:

Copy>>> 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
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
'str' object has no attribute 'decode' Error When Trying To Decode a HTML response
The error is telling you that strings don't have a decode method. So yes, http_response is a string and that fact is exactly why this error is occurring. More on reddit.com
🌐 r/learnpython
7
1
October 13, 2020
🌐
DataCamp
datacamp.com › tutorial › bytes-to-string-python
How to Convert Bytes to String in Python | DataCamp
June 12, 2024 - The .decode() method returns a string representing the bytes object. In this example, UTF-8 decoding is used. UTF-8 is the default encoding, so it's not required in the example above, but we can also use other encodings. Python has a built-in bytes data structure, which is an immutable sequence ...
🌐
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....
🌐
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
🌐
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.
🌐
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
🌐
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.
🌐
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.
🌐
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.
🌐
Code Beautify
codebeautify.org › byte-to-string
Best Byte to String Online Converter
Byte to String Converter helps to convert Byte buffer to String, which help users to decode bytes into readable texts with free and easy to use tool. Converting Byte Array to String helps you to view and read your Byte data as 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
🌐
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)
🌐
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".
🌐
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.
🌐
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 ...
🌐
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....
🌐
Scaler
scaler.com › home › topics › byte to string python
Byte to String Python - Scaler Topics
January 16, 2024 - The above code will produce a byte string. Python will render it as b'I am a string' if you print it. However, keep in mind that byte strings are not human-readable; Python decodes them from ASCII when you print them.
🌐
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.
🌐
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 ...