Cleaner version:

>>> test_string = '1101100110000110110110011000001011011000101001111101100010101000'
>>> print ('%x' % int(test_string, 2)).decode('hex').decode('utf-8')
نقاب

Inverse (from @Robᵩ's comment):

>>> '{:b}'.format(int(u'نقاب'.encode('utf-8').encode('hex'), 16))
1: '1101100110000110110110011000001011011000101001111101100010101000'
Answer from Igonato on Stack Overflow
🌐
AskPython
askpython.com › python › examples › binary-to-utf8-conversion
How to Convert Binary Data to UTF-8 in Python - AskPython
April 10, 2025 - Base64 produces UTF-8 compatible text output from any binary input. import base64 data = b"\x12\xab" # Base64 encode b64_data = base64.b64encode(data) # Now decode base64 text from UTF-8 to string text = b64_data.decode("utf-8") print(text) ...
Discussions

how do i convert string to binary string and the reverse too?
If you simply want to see the string output in binary, I just do: print(bin(yournumberhere)) More on reddit.com
🌐 r/learnpython
3
1
October 27, 2022
utf 8 - python - convert binary data to utf-8 - Stack Overflow
import base64 encoded = base64.b64encode(image_binary_data) ... Encoding means converting strings to storable bytes. And Decoding means converting bytes to readable strings. The data in your code is already encoded. ... Image cannot be converted into something like charters in utf8. ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 1 How to convert a string representation of 'bytes' to its corresponding 'utf-8' in Python... More on stackoverflow.com
🌐 stackoverflow.com
python - How to convert 'binary string' to normal string in Python3? - Stack Overflow
For example, I have a string like this(return value of subprocess.check_output): >>> b'a string' b'a string' Whatever I did to it, it is always printed with the annoying b' before the str... More on stackoverflow.com
🌐 stackoverflow.com
March 30, 2016
python - Convert UTF-8 as string of binary 0 and 1s to code point - Stack Overflow
If you have a string of bits, how do you convert that into the correct code point if that string of 0s and 1s is in utf-8 encoding. For example: accented_a_part1 = "100001" accented_a_par... More on stackoverflow.com
🌐 stackoverflow.com
June 4, 2017
🌐
CodeRivers
coderivers.org › blog › python-binary-to-string
Python Binary to String: A Comprehensive Guide - CodeRivers
February 22, 2026 - The most straightforward way to convert binary data to a string in Python is by using the decode() method on a bytes object. The decode() method takes an encoding parameter, which specifies how the binary data should be decoded. The most common encoding is 'utf - 8'. binary_data = b'hello' ...
🌐
GitHub
github.com › glmcdona › binary2strings
GitHub - glmcdona/binary2strings: Python module to extract Ascii, Utf8, and Unicode strings from binary data. Lightning fast wrapper around c++ compiled code. · GitHub
encoding: "UTF8" | "WIDE_STRING". This is the encoding of the original string within the binary buffer. span: (start, end) tuple describing byte indices of where the string starts and ends within the buffer. is_interesting: Boolean describing ...
Author: glmcdona
Find elsewhere
🌐
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 - We specify the encoding format as utf-8 using the encoding parameter. Finally, we print the resulting string to the console. We can also use the bytes() constructor, a built-in Python function used to create a new bytes object. It takes an iterable of integers as input and returns a new bytes object that contains the corresponding bytes. This is useful when we are working with binary data, or when converting between different types of data that use bytes as their underlying representation.
🌐
Online Tools
onlinetools.com › utf8 › convert-binary-to-utf8
Convert Binary Bits to UTF8 – Online UTF8 Tools
With this tool you can easily convert raw binary bits, zeros and ones, to UTF8-encoded text. It assumes input is always 7-bit or 8-bit aligned.
🌐
Milddev
milddev.com › python-binary-to-string
Python Binary to String Guide
July 28, 2025 - That mapping is defined by an encoding, ... most straightforward way to convert binary data into a Python string is using the decode method on a bytes object....
🌐
Python Guides
pythonguides.com › convert-string-to-utf-8-in-python
How To Convert String To UTF-8 In Python
May 16, 2025 - By using .encode() and .decode() methods, you can easily switch between text and binary formats, making your code robust when handling files, APIs, or hardware data streams. ... In this article, I have explained how to convert string to UTF-8 in Python. I discussed three methods to accomplish this task such as using the .encode('utf-8), using the bytes() constructor, and .encode('utf-8) with error handling.
🌐
GeeksforGeeks
geeksforgeeks.org › convert-binary-to-string-using-python
Convert binary to string using Python - GeeksforGeeks
April 12, 2025 - The goal is to interpret the binary data, where each group of 8 bits represents a character and decode it into its corresponding text. For example, the binary string '01100111011001010110010101101011' converts to 'geek'.
🌐
Learning Python
learning-python.com › strings30.html
Python 3.X Strings Tutorial by Mark Lutz
Along similar lines, the Python struct module, used to create and extract packed binary data from strings, works in 3.0 as it does in 2.X but in 3.X operates on bytes and bytearray only, not str (which makes sense, given that it's intended for processing binary data, not decoded text): >>> import struct >>> B = struct.pack('>i4sh', 7, b'spam', 8) # 's' requires bytes as of 3.2 >>> B # (it encodes str as utf8 in 3.0/3.1) b'\x00\x00\x00\x07spam\x00\x08' >>> >>> vals = struct.unpack('>i4sh', B) # packed data is bytes, not str >>> vals (7, b'spam', 8) >>> >>> vals = struct.unpack('>i4sh', B.decode()) TypeError: 'str' does not have the buffer interface
🌐
Real Python
realpython.com › python-bytes
Bytes Objects: Handling Binary Data in Python – Real Python
March 5, 2025 - To decipher foreign Unicode characters, which may be encoded using more than one byte, you’ll have to specify the respective character encoding: ... >>> data = [0x63, 0x61, 0x66, 0xc3, 0xa9] >>> bytes(data).decode("utf-8") 'café' >>> ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › convert-a-string-to-utf-8-in-python
Convert a String to Utf-8 in Python - GeeksforGeeks
July 23, 2025 - In this example, the encode method is called on the original_string with the argument 'utf-8'. The result is a bytes object containing the UTF-8 representation of the original string.