If you just need the binary data in the strings and can recover the boundaries between the individual strings easily, you could just write them to a file directly, as raw strings.

If you can't recover the string boundaries easily, JSON seems like a good option:

a = [b"abc\xf3\x9c\xc6", b"xyz"]
serialised = json.dumps([s.decode("latin1") for s in a])
print [s.encode("latin1") for s in json.loads(serialised)]

will print

['abc\xf3\x9c\xc6', 'xyz']

The trick here is that arbitrary binary strings are valid latin1, so they can always be decoded to Unicode and encoded back to the original string again.

Answer from Sven Marnach on Stack Overflow
🌐
The Hitchhiker's Guide to Python
docs.python-guide.org › scenarios › serialization
Data Serialization — The Hitchhiker's Guide to Python
Serializing Text · Simple file (flat data) repr · ast.literal_eval · CSV file (flat data) YAML (nested data) JSON file (nested data) XML (nested data) Binary · NumPy Array (flat data) Pickle (nested data) Protobuf · Documentation overview · Previous: Image Manipulation ·
🌐
Python
docs.python.org › 3 › library › pickle.html
pickle — Python object serialization
February 23, 2026 - JSON is a text serialization format (it outputs unicode text, although most of the time it is then encoded to utf-8), while pickle is a binary serialization format;
🌐
Medium
gaurav-adarshi.medium.com › serialization-techniques-in-python-297a4489ba87
Serialization techniques in Python | by Gaurav Kumar | Medium
April 24, 2024 - The marshal module in Python provides a way to serialize and deserialize Python objects into a binary format.
🌐
Python for the Lab
pythonforthelab.com › blog › storing-binary-data-and-serializing
Storing Binary Data and Serializing | Python For The Lab
August 11, 2018 - The algorithm responsible for serializing the information is particular to Python and therefore it is not compatible out of the box with other programming languages.
🌐
Real Python
realpython.com › python-serialize-data
Serialize Your Data With Python – Real Python
December 4, 2023 - As you’ve learned, pickle is the standard data serialization format in Python, and it’s capable of representing a wide range of native data types as well as user-defined classes. It’s a binary format specific to Python, which requires no schema definition and can handle data in almost any shape or form.
🌐
MojoAuth
mojoauth.com › serialize-and-deserialize › serialize-and-deserialize-binary-with-python
Serialize and Deserialize Binary with Python | Serialize & Deserialize Data Across Languages
September 28, 2025 - You'll learn to handle complex ... formats like JSON for binary data. Python's built-in pickle module offers a straightforward way to serialize most Python objects into a binary format....
🌐
MachineLearningMastery
machinelearningmastery.com › home › blog › a gentle introduction to serialization for python
A Gentle Introduction to Serialization for Python - MachineLearningMastery.com
June 21, 2022 - Hierarchical Data Format 5 (HDF5) is a binary data format. The h5py package is a Python library that provides an interface to the HDF5 format. From h5py docs, HDF5 “lets you store huge amounts of numerical data, and easily manipulate that data from Numpy.” · What HDF5 can do better than other serialization formats is store data in a file system-like hierarchy.
Find elsewhere
🌐
GitHub
github.com › nannafudge › bran
GitHub - nannafudge/bran: Simple python serialization/deserialization library
(Py)Bran - Boring, plain and simple python binary serialization/deserialization library
Author   nannafudge
🌐
GitHub
github.com › explosion › srsly
GitHub - explosion/srsly: 🦉 Modern high-performance serialization utilities for Python (JSON, MessagePack, Pickle)
14 hours ago - This package bundles some of the best Python serialization libraries into one convenience package, with a high-level API that makes it easy to write code that's correct across platforms and Pythons. This allows us to provide all the serialization utilities we need in a single binary wheel.
Starred by 481 users
Forked by 38 users
Languages   Python 99.3% | Shell 0.7%
🌐
Udacity
udacity.com › blog › 2020 › 12 › python-serialization-getting-started.html
Python Serialization: Getting Started | Udacity
October 24, 2024 - In this article, we’ll cover ... objects in Python. Serialization is the process of converting a data object from its original in-memory structure into a binary or text-based format....
🌐
Python
docs.python.org › 3.3 › library › pickle.html
12.1. pickle — Python object serialization — Python 3.3.7 documentation
The pickle module implements binary protocols for serializing and de-serializing a Python object structure.
🌐
Tutorialspoint
tutorialspoint.com › python › python_serialization.htm
Python - Serialization
Deserialization, or unpickling, is the reverse process, converting the byte stream back into a Python object. We can serialize an object using the dump() function and write it to a file. The file must be opened in binary write mode ('wb').
🌐
DataFlair
data-flair.training › blogs › python-pickle
Python Pickle | What is Serialization in Python with Example - DataFlair
July 19, 2025 - Simply speaking, Python serialization is the act of converting a Python object into a byte stream. In Python, we use the module ‘pickle’, which has a binary serializable format.
🌐
Python
docs.python.org › 3.4 › library › pickle.html
12.1. pickle — Python object serialization — Python 3.4.10 documentation
June 16, 2019 - The pickle module implements binary protocols for serializing and de-serializing a Python object structure.
🌐
SSOJet
ssojet.com › home › serialize and deserialize binary in python
Serialize and Deserialize Binary in Python | SSOJet
March 1, 2025 - This article dives into Python's built-in `pickle` module, demonstrating how to serialize (convert objects to byte streams) and deserialize (reconstruct objects from byte streams). You'll learn best practices for handling binary data, ensuring reliable data transfer and storage for your projects.
🌐
Diveintopython3
diveintopython3.net › serializing.html
Serializing Python Objects - Dive Into Python 3
This is still in Python Shell #1. Use the open() function to open a file. Set the file mode to 'wb' to open the file for writing in binary mode. Wrap it in a with statement to ensure the file is closed automatically when you’re done with it. The dump() function in the pickle module takes a serializable Python data structure, serializes it into a binary, Python-specific format using the latest version of the pickle protocol, and saves it to an open file.
🌐
GitHub
github.com › monkeyman192 › BinSerialize
GitHub - monkeyman192/BinSerialize: Easily serialize and deserialize binary data using python. · GitHub
Easily serialize and deserialize binary data using python. - monkeyman192/BinSerialize
Author   monkeyman192
🌐
GitHub
github.com › metachris › binary-serializer
GitHub - metachris/binary-serializer: Minimalistic binary serialization protocol (a la protocol buffers) with Python and Java implementations.
November 3, 2022 - Minimalistic binary serialization protocol (a la protocol buffers) with Python and Java implementations. - metachris/binary-serializer
Author   metachris