**Update (NumPy 1.19+):** Note that `.tostring()` is deprecated since NumPy 1.19. Use `.tobytes()` instead, which has identical behavior.

You can use the fromstring() method for this:

arr = np.array([1, 2, 3, 4, 5, 6])
ts = arr.tostring()
print(np.fromstring(ts, dtype=int))

>>> [1 2 3 4 5 6]

Sorry for the short answer, not enough points for commenting. Remember to state the data types or you'll end up in a world of pain.

Note on fromstring from numpy 1.14 onwards:

sep : str, optional

The string separating numbers in the data; extra whitespace between elements is also ignored.

Deprecated since version 1.14: Passing sep='', the default, is deprecated since it will trigger the deprecated binary mode of this function. This mode interprets string as binary bytes, rather than ASCII text with decimal numbers, an operation which is better spelt frombuffer(string, dtype, count). If string contains unicode text, the binary mode of fromstring will first encode it into bytes using either utf-8 (python 3) or the default encoding (python 2), neither of which produce sane results.

Answer from ajsp on Stack Overflow
Top answer
1 of 9
55

**Update (NumPy 1.19+):** Note that `.tostring()` is deprecated since NumPy 1.19. Use `.tobytes()` instead, which has identical behavior.

You can use the fromstring() method for this:

arr = np.array([1, 2, 3, 4, 5, 6])
ts = arr.tostring()
print(np.fromstring(ts, dtype=int))

>>> [1 2 3 4 5 6]

Sorry for the short answer, not enough points for commenting. Remember to state the data types or you'll end up in a world of pain.

Note on fromstring from numpy 1.14 onwards:

sep : str, optional

The string separating numbers in the data; extra whitespace between elements is also ignored.

Deprecated since version 1.14: Passing sep='', the default, is deprecated since it will trigger the deprecated binary mode of this function. This mode interprets string as binary bytes, rather than ASCII text with decimal numbers, an operation which is better spelt frombuffer(string, dtype, count). If string contains unicode text, the binary mode of fromstring will first encode it into bytes using either utf-8 (python 3) or the default encoding (python 2), neither of which produce sane results.

2 of 9
28

If you use tostring you lose information on both shape and data type:

>>> import numpy as np
>>> a = np.arange(12).reshape(3, 4)
>>> a
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11]])
>>> s = a.tostring()
>>> aa = np.fromstring(a)
>>> aa
array([  0.00000000e+000,   4.94065646e-324,   9.88131292e-324,
         1.48219694e-323,   1.97626258e-323,   2.47032823e-323,
         2.96439388e-323,   3.45845952e-323,   3.95252517e-323,
         4.44659081e-323,   4.94065646e-323,   5.43472210e-323])
>>> aa = np.fromstring(a, dtype=int)
>>> aa
array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11])
>>> aa = np.fromstring(a, dtype=int).reshape(3, 4)
>>> aa
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11]])

This means you have to send the metadata along with the data to the recipient. To exchange auto-consistent objects, try cPickle:

>>> import cPickle
>>> s = cPickle.dumps(a)
>>> cPickle.loads(s)
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11]])
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.array2string.html
numpy.array2string — NumPy v2.5 Manual
Return a string representation of an array. ... Input array. ... Inserts newlines if text is longer than max_line_width. Defaults to numpy.get_printoptions()['linewidth'].
Discussions

How do I convert Numpy Array to a List of Strings?
what is x ? Can you share small snippet of your code? More on reddit.com
🌐 r/learnpython
6
1
December 2, 2020
Convert elements in a numpy array to string - Stack Overflow
(I used coords = '259467.2,2737833.87' and got the string form which was what I want: 259467.2,2737833.87) How to convert elements in a numpy array to string with a comma? More on stackoverflow.com
🌐 stackoverflow.com
How do I convert a string into a numpy array?
Have you looked at the docs at all? Perhaps this will get you started. If the data is in the format you indicate, I’d reach for pandas, another python library that is built on top of numpy. More on reddit.com
🌐 r/learnprogramming
2
1
May 13, 2020
Editing a String Item in Numpy Array
Unlike lists, Numpy expects every element of the array to be the same type. When you convert your list of strings, Numpy is tries be efficient and says “This is a list of strings. The longest string is 6 characters. I’m going to assume that the datatype is a string of 6 characters.” This is what datatype ‘ More on reddit.com
🌐 r/learnpython
3
0
March 11, 2023
🌐
Python Guides
pythonguides.com › convert-numpy-array-to-list-of-strings-in-python
Convert NumPy Array to String in Python (6 Easy Methods)
May 15, 2025 - Learn 6 practical methods to convert NumPy arrays to strings in Python, with real-world examples and formatting tips for data analysis and reporting.
🌐
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.array2string.html
numpy.array2string — NumPy v2.3 Manual
Return a string representation of an array. ... Input array. ... Inserts newlines if text is longer than max_line_width. Defaults to numpy.get_printoptions()['linewidth'].
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.array2string.html
numpy.array2string — NumPy v2.2 Manual
Return a string representation of an array. ... Input array. ... Inserts newlines if text is longer than max_line_width. Defaults to numpy.get_printoptions()['linewidth'].
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-array_str-in-python
numpy.array_str() in Python - GeeksforGeeks
November 29, 2018 - numpy.array_str()function is used to represent the data of an array as a string. The data in the array is returned as a single string.
🌐
Appdividend
appdividend.com › converting-numpy-array-to-string-in-python
How to Convert a Numpy Array to String in Python
September 7, 2025 - The np.array2string() method returns a string representation of the array. This method allows us to control precision, separator, and line width. import numpy as np arr = np.array([1.21, 2.22, 3.19, 4.5]) str_arr = np.array2string(arr) ...
Find elsewhere
🌐
IncludeHelp
includehelp.com › python › how-to-convert-a-numpy-ndarray-to-string-or-bytes-and-convert-it-back-to-nump-ndarray.aspx
Python - How to convert a numpy.ndarray to string(or bytes) and convert it back to numpy.ndarray?
February 25, 2023 - We can convert a numpy ndarray using tostring() method and to convert this string back into the form of a numpy ndarray, we can use numpy.fromstring() method and also we need to define the data type of the elements. ... # Import numpy import numpy as np # Creating a numpy array arr = np.array([1, ...
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.ndarray.tostring.html
numpy.ndarray.tostring — NumPy v2.1 Manual
A compatibility alias for tobytes, with exactly the same behavior · Despite its name, it returns bytes not strs
🌐
NumPy
numpy.org › devdocs › user › basics.strings.html
Working with Arrays of Strings And Bytes — NumPy v2.6.dev0 Manual
The numpy.bytes_ cast is most useful for string data that is known to contain only ASCII characters, as characters outside this range cannot be represented in a single byte in the UTF-8 encoding and are rejected. When converting an array to a fixed-width string dtype with an unspecified size using numpy.ndarray.astype, NumPy infers the size by inspecting the array values, producing a dtype wide enough to store the widest entry without truncation:
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.array2string.html
numpy.array2string — NumPy v2.6.dev0 Manual
Return a string representation of an array. ... Input array. ... Inserts newlines if text is longer than max_line_width. Defaults to numpy.get_printoptions()['linewidth'].
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.array2string.html
numpy.array2string — NumPy v2.1 Manual
Return a string representation of an array. ... Input array. ... Inserts newlines if text is longer than max_line_width. Defaults to numpy.get_printoptions()['linewidth'].
🌐
NumPy
numpy.org › doc › 1.13 › reference › generated › numpy.array2string.html
numpy.array2string — NumPy v1.13 Manual
>>> x = np.arange(3) >>> np.array2string(x, formatter={'int':lambda x: hex(x)}) '[0x0L 0x1L 0x2L]'
🌐
SciPy
docs.scipy.org › doc › numpy-1.12.0 › reference › generated › numpy.array2string.html
numpy.array2string — NumPy v1.12 Manual
numpy.array2string(a, max_line_width=None, precision=None, suppress_small=None, separator=' ', prefix='', style=<built-in function repr>, formatter=None)[source]¶ · Return a string representation of an array.
🌐
w3resource
w3resource.com › numpy › input-and-output › array2string.php
NumPy Input and Output: array2string() function - w3resource
May 2, 2026 - The array2string() function is used to get a string representation of an array. ... numpy.array2string(a, max_line_width=None, precision=None, suppress_small=None, separator=' ', prefix='', style=<no value>, formatter=None, threshold=None, ...
🌐
NumPy
numpy.org › doc › 2.0 › reference › generated › numpy.array2string.html
numpy.array2string — NumPy v2.0 Manual
Return a string representation of an array. ... Input array. ... Inserts newlines if text is longer than max_line_width. Defaults to numpy.get_printoptions()['linewidth'].