gives the depth to which expr is a full array, with all the parts at a particular level having the same length.

Details and Options


open allclose all

Basic Examples  (1)

Find the depth to which an array is full:

Scope  (4)

ArrayDepth counts only dimensions at which an expression is not "ragged":

ArrayDepth works with special array types, including SparseArray objects:

SymmetrizedArray objects:

NumericArray objects:

Find the depth of a matrix that is a mixture of List and different special array heads:

ArrayDepth works with any head, not just List:

Options  (4)

AllowedHeads  (4)

Only consider nested expressions with head List:

By default, rectangular nested expressions with any head are considered arrays:

Allow lists and numeric arrays at different levels:

Different heads cannot be mixed at the same level:

Allow a mixture of both heads at the same level:

Allow List as well as other general array representations:

Only allow the head List:

Both settings disallow general heads:

Allow any head at each level of the array:

An array has a consistent head at each level:

Completely ignore heads, looking only at the tree structure of the expression:

Properties & Relations  (8)

Length[Dimensions[expr]] equals ArrayDepth[expr]:

ArrayDepth always returns a non-negative integer:

The default value of the option AllowedHeads allows mixtures of list, sparse and structured arrays:

It also allows any single head at successive levels:

The following setting of AllowedHeads imitates the default behavior with respect to list-like arrays:

However, it excludes arbitrary heads:

VectorQ, MatrixQ and ArrayQ effectively use AllowedHeads"ListLike":

The setting AllowedHeads"ListLike" does not include ByteArray and NumericArray:

Combine "ListLike" with the additional heads to allow the combination:

ArrayDepth[Array[h,dims]] gives Length[dims]:

ArrayDepth only considers the the levels to which the expression is completely rectangular:

Depth considers the deepest part of an expression:

For completely rectangular expressions, ArrayDepth gives a result one small than Depth:

Possible Issues  (1)

Numeric expressions report array depth based of the structure of their FullForm:

To treat all numeric expressions as scalars, use the setting List or "ListLike" for AllowedHeads:

Wolfram Research (2003), ArrayDepth, Wolfram Language function, (updated 2020).


Wolfram Research (2003), ArrayDepth, Wolfram Language function, (updated 2020).


@misc{reference.wolfram_2020_arraydepth, author="Wolfram Research", title="{ArrayDepth}", year="2020", howpublished="\url{}", note=[Accessed: 16-January-2021 ]}


@online{reference.wolfram_2020_arraydepth, organization={Wolfram Research}, title={ArrayDepth}, year={2020}, url={}, note=[Accessed: 16-January-2021 ]}


Wolfram Language. 2003. "ArrayDepth." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020.


Wolfram Language. (2003). ArrayDepth. Wolfram Language & System Documentation Center. Retrieved from