For a nested Python list that follows an array’s dimensions, use arr.tolist(). It also converts NumPy scalar values to compatible built-in Python scalars. One exception: a zero-dimensional array returns a scalar, not a list.
Assume NumPy is imported as np and your array is named arr. The examples below show which method to use for nested output, a flat sequence, or explicit row-by-row conversion.
1. Use arr.tolist() for a nested Python list
This is the general-purpose choice. NumPy’s ndarray.tolist() documentation describes the result as an a.ndim-levels-deep nested list of Python scalars. It preserves the array’s dimensional structure in the lists and converts array scalars to compatible Python scalar types.
import numpy as np
arr = np.array([[1, 2], [3, 4]])
result = arr.tolist()
# result: [[1, 2], [3, 4]]
The returned containers and values are a copy; changing the list does not edit the original array.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
2. Use list(arr) for a one-dimensional array
For a 1-D array, list(arr) produces a Python list, but its elements remain NumPy scalar values. That differs from tolist(), which converts them to compatible built-in Python scalars.
arr = np.array([1, 2, 3])
result = list(arr)
# result: [np.int64(1), np.int64(2), np.int64(3)]
# Element types depend on the array's dtype and NumPy version.
For a 2-D array, list(arr) iterates over the first axis and returns row arrays, not a nested Python list. NumPy’s examples illustrate this distinction between list() and tolist().
Rank #2
3. Use list(map(list, arr)) for explicit 2-D row conversion
If the array is two-dimensional and you want to convert each row explicitly, map list() over the rows:
arr = np.array([[1, 2], [3, 4]])
result = list(map(list, arr))
# result: [[1, 2], [3, 4]]
This is a row-by-row conversion for 2-D input. For arrays with more dimensions, it does not recursively convert every nested level; use arr.tolist() instead.
Recommended Free Tools
4. Use arr.flatten().tolist() when you want one flat list
Flattening removes the original multidimensional arrangement before the values are converted to a list. Choose it only when you want a single sequence rather than nested rows.
arr = np.array([[1, 2], [3, 4]])
result = arr.flatten().tolist()
# result: [1, 2, 3, 4]
5. Use a list comprehension when you want to show the iteration
For 1-D input, a comprehension makes the iteration visible, but its elements remain NumPy scalars, as with list(arr).
arr = np.array([1, 2, 3])
result = [x for x in arr]
For 2-D input, convert each row with tolist() to preserve the two-level shape as Python lists:
arr = np.array([[1, 2], [3, 4]])
result = [row.tolist() for row in arr]
# result: [[1, 2], [3, 4]]
For arbitrary dimensions, prefer the recursive arr.tolist() method rather than adding nested iteration manually.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Best Value
Which method should you choose?
| Method | Input dimensionality | Output shape | Element types |
|---|---|---|---|
arr.tolist() |
Any; a 0-D array is a special case | Nested lists following the array dimensions; 0-D input returns a scalar | Compatible Python scalars |
list(arr) |
Best suited to 1-D | One list for 1-D input; row arrays for 2-D input | NumPy scalars for 1-D input |
list(map(list, arr)) |
2-D | List of row lists | Values yielded by applying Python list() to each row |
arr.flatten().tolist() |
Any array with values | One flat list; original arrangement is removed | Compatible Python scalars |
| List comprehension | 1-D or 2-D, depending on expression | 1-D list, or two-level list with [row.tolist() for row in arr] |
NumPy scalars for [x for x in arr]; compatible Python scalars for converted rows |
Handle zero-dimensional arrays and round trips carefully
A 0-D array returns a scalar
Because a zero-dimensional array has no list-shaped dimension, arr.tolist() returns a scalar. If you specifically need a one-item list, wrap the scalar explicitly:
arr = np.array(7)
result = [arr.item()]
# result: [7]
This creates a different output shape from calling arr.tolist().
Rebuilding an array may lose precision
You can construct an array from a list with np.array(arr.tolist()), but NumPy warns that converting to a list and back can sometimes lose precision. Do not assume this round trip is always lossless; if preserving the array representation matters, avoid using a Python list as an intermediate format.
The API details here correspond to NumPy’s stable documentation, whose version label is 2.5: tolist(), array creation and examples, and data types.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




