List functions

List functions return lists of different data entities.

For more information about working with LIST values, see:

Example graph

The following graph is used for the examples below:

To recreate the graph, run the following query against an empty Neo4j database:

CREATE
  (alice:Developer {name:'Alice', age: 38, eyes: 'Brown'}),
  (bob:Administrator {name: 'Bob', age: 25, eyes: 'Blue'}),
  (charlie:Administrator {name: 'Charlie', age: 53, eyes: 'Green'}),
  (daniel:Administrator {name: 'Daniel', age: 54, eyes: 'Brown'}),
  (eskil:Designer {name: 'Eskil', age: 41, eyes: 'blue', likedColors: ['Pink', 'Yellow', 'Black']}),
  (alice)-[:KNOWS]->(bob),
  (alice)-[:KNOWS]->(charlie),
  (bob)-[:KNOWS]->(daniel),
  (charlie)-[:KNOWS]->(daniel),
  (bob)-[:MARRIED]->(eskil)

coll.distinct()

Details

Syntax

coll.distinct(list)

Description

Returns the given list with all duplicate values removed.

Arguments

Name

Type

Description

list

LIST<ANY>

A list to be deduplicated.

Returns

LIST<ANY>

Considerations

coll.distinct(null) returns null.

The order of the first occurrences of the distinct values is preserved.

Example 1. coll.distinct()
Deduplicate a list of integer values
RETURN coll.distinct([1, 3, 2, 4, 2, 3, 1])

A LIST<ANY> containing only unique values is returned.

Result
coll.distinct([1, 3, 2, 4, 2, 3, 1])

[1, 3, 2, 4]

Rows: 1

Deduplicate a list of mixed values, including null
RETURN coll.distinct([1, true, true, null, 'a', false, true, 1, null])

A LIST<ANY> containing only unique values is returned.

Result
coll.distinct([1, true, true, null, 'a', false, true, 1, null])

[1, true, null, 'a', false]

Rows: 1

coll.flatten()

Details

Syntax

coll.flatten(list [, depth])

Description

Returns a list flattened to the given nesting depth.

Arguments

Name

Type

Description

list

LIST<ANY>

A nested list to be flattened.

depth

INTEGER

The maximum depth to flatten to (default value: 1).

Returns

LIST<ANY>

Considerations

Preserves the original order of non-list items.

If depth is 0, the input list is returned unchanged.

depth must be a non-negative integer.

coll.flatten(null) returns null.

coll.flatten(list, null) returns null.

coll.flatten(null, depth) returns null.

coll.flatten(null, null) returns null.

Example 2. coll.flatten()
Flatten a list containing nesting to level 2
RETURN coll.flatten(['a', ['b', ['c']]], 2)

A LIST<ANY> with any inner lists up to a nesting depth of 2 flattened.

Result
coll.flatten(['a', ['b', ['c']]], 2)

['a', 'b', 'c']

Rows: 1

Flatten a list to default of depth 1
RETURN coll.flatten(['a', ['b', ['c']]])

A LIST<ANY> with any inner lists up to a nesting depth of 1 (default depth) flattened.

Result
coll.flatten(['a', ['b', ['c']]])

['a', 'b', ['c']]

Rows: 1

coll.hasAllOf()

Details

Syntax

coll.hasAllOf(list, subset)

Description

Returns true if every element of subset is in list, false if any is missing, and null if the result cannot be determined.

Arguments

Name

Type

Description

list

LIST<ANY>

The list to search for the elements of subset.

subset

LIST<ANY>

The elements that must all be present in list.

Returns

BOOLEAN

Considerations

Duplicates in subset are ignored: an element only needs to appear in list at least once. For example, coll.hasAllOf([1, 2, 3], [1, 1, 2, 2, 3, 3]) returns true.

Returns true if subset is an empty list.

coll.hasAllOf(list, subset) is equivalent to all(x IN subset WHERE x IN list).

A null element in either list is treated as an unknown value. If any element is definitely missing in subset, the result is false (e.g., coll.hasAllOf([1, 2], [3, null]). If a null leaves a match unknown, the result is null (e.g., coll.hasAllOf([1, 2], [1, null]).

coll.hasAllOf(null, subset), coll.hasAllOf(list, null) and coll.hasAllOf(null, null) return null.

Example 3. coll.hasAllOf()
Check that a list contains all values of another list
RETURN coll.hasAllOf([1, 2, 3, 4], [2, 4])
Result
coll.hasAllOf([1, 2, 3, 4], [2, 4])

true

Rows: 1

Duplicates in the subset are ignored
RETURN coll.hasAllOf([1, 2, 3], [1, 1, 2, 2, 3, 3])
Result
coll.hasAllOf([1, 2, 3], [1, 1, 2, 2, 3, 3])

true

Rows: 1

A value in the subset is missing from the list
RETURN coll.hasAllOf([1, 2, 3], [3, 4])
Result
coll.hasAllOf([1, 2, 3], [3, 4])

false

Rows: 1

null in the subset is an unknown value
RETURN coll.hasAllOf([1, 2, 3], [1, null])
Result
coll.hasAllOf([1, 2, 3], [1, null])

null

Rows: 1

coll.hasAnyOf()

Details

Syntax

coll.hasAnyOf(list1, list2)

Description

Returns true if any element of list1 is also in list2, false if none are, and null if the result cannot be determined.

Arguments

Name

Type

Description

list1

LIST<ANY>

The list to search for any element of list2.

list2

LIST<ANY>

The elements to search for in list1.

Returns

BOOLEAN

Considerations

Returns false if either list is empty.

coll.hasAnyOf(list1, list2) is equivalent to any(x IN list2 WHERE x IN list1).

A null element in either list is treated as an unknown value. If any element of list2 is definitely found in list1, the result is true (e.g., coll.hasAnyOf([1, 2], [1, null])). If no match is found but a null leaves a match unknown, the result is null (e.g., coll.hasAnyOf([1, 2], [3, null])).

coll.hasAnyOf(null, list2), coll.hasAnyOf(list1, null) and coll.hasAnyOf(null, null) return null.

Example 4. coll.hasAnyOf()
Check that two lists share at least one value
RETURN coll.hasAnyOf([1, 2, 3], [3, 4, 5])
Result
coll.hasAnyOf([1, 2, 3], [3, 4, 5])

true

Rows: 1

The lists share no values
RETURN coll.hasAnyOf([1, 2, 3], [4, 5, 6])
Result
coll.hasAnyOf([1, 2, 3], [4, 5, 6])

false

Rows: 1

null in the first list is an unknown value
RETURN coll.hasAnyOf([1, null], [3])
Result
coll.hasAnyOf([1, null], [3])

null

Rows: 1

coll.hasNoneOf()

Details

Syntax

coll.hasNoneOf(list1, list2)

Description

Returns true if no element of list1 is in list2, false if any is, and null if the result cannot be determined.

Arguments

Name

Type

Description

list1

LIST<ANY>

The list to search for any element of list2.

list2

LIST<ANY>

The elements to look for in list1.

Returns

BOOLEAN

Considerations

Returns true if either list is empty.

coll.hasNoneOf(list1, list2) is equivalent to none(x IN list2 WHERE x IN list1).

A null element in either list is treated as an unknown value. If any element of list2 is definitely found in list1, the result is false (e.g., coll.hasNoneOf([1, 2], [1, null])). If no match is found but a null leaves a match unknown, the result is null (e.g., coll.hasNoneOf([1, 2], [3, null])).

coll.hasNoneOf(null, list2), coll.hasNoneOf(list1, null) and coll.hasNoneOf(null, null) return null.

Example 5. coll.hasNoneOf()
Check that two lists share no values
RETURN coll.hasNoneOf([1, 2, 3], [4, 5, 6])
Result
coll.hasNoneOf([1, 2, 3], [4, 5, 6])

true

Rows: 1

The lists share a value
RETURN coll.hasNoneOf([1, 2, 3], [3, 4, 5])
Result
coll.hasNoneOf([1, 2, 3], [3, 4, 5])

false

Rows: 1

null in the first list is an unknown value
RETURN coll.hasNoneOf([1, null], [3])
Result
coll.hasNoneOf([1, null], [3])

null

Rows: 1

coll.indexOf()

Details

Syntax

coll.indexOf(list, value)

Description

Returns the index of the first match of a value in the given list or -1 if the value is not present.

Arguments

Name

Type

Description

list

LIST<ANY>

A list to be searched.

value

ANY

A value to search for.

Returns

INTEGER

Considerations

Indexing is 0-based.

Returns -1 if the value is not present in the list.

coll.indexOf(null, null) returns null.

coll.indexOf(null, value) returns null.

coll.indexOf(list, null) returns null.

Example 6. coll.indexOf()
Find the first index of a given value
RETURN coll.indexOf(['a', 'b', 'c', 'c'], 'c')

An INTEGER representing the index of the item in the list.

Result
coll.indexOf(['a', 'b', 'c', 'c'], 'c')

2

Rows: 1

Search for a value not present in the given list
RETURN coll.indexOf([1, 'b', false], 4.3)

The INTEGER -1 representing that the value is not found.

Result
coll.indexOf([1, 'b', false], 4.3)

-1

Rows: 1

coll.insert()

Details

Syntax

coll.insert(list, index, value)

Description

Returns a list with the given value inserted at the given index.

Arguments

Name

Type

Description

list

LIST<ANY>

A list to add to.

index

INTEGER

The index to add the given value at.

value

ANY

The value to add into the list.

Returns

LIST<ANY>

Considerations

Indexing is 0-based.

coll.insert(null, null, value) returns null.

coll.insert(list, null, value) returns null.

coll.insert(null, 1, value) returns null.

If the given index is negative or larger than the size of the given list, an error is returned.

Example 7. coll.insert()
Query
RETURN coll.insert([true, 'a', 1, 5.4], 1, false)

The original list with a new value inserted at the given index, shifting all the values following by 1.

Result
coll.insert([true, 'a', 1, 5.4], 1, false)

[true, false, 'a', 1, 5.4]

Rows: 1

coll.max()

Details

Syntax

coll.max(list)

Description

Returns the largest value present in the given list.

Arguments

Name

Type

Description

list

LIST<ANY>

A list to be searched.

Returns

ANY

Considerations

coll.max(null) returns null.

coll.max([]) returns null.

The maximum is determined using Cypher®'s standard value ordering; see Equality, ordering, and comparison of value types.

Example 8. coll.max()
Query
RETURN coll.max([true, 'a', 1, 5.4])

The maximum value found in the given list based on Cypher’s ordering.

Result
coll.max([true, 'a', 1, 5.4])

5.4

Rows: 1

coll.min()

Details

Syntax

coll.min(list)

Description

Returns the smallest value present in the given list.

Arguments

Name

Type

Description

list

LIST<ANY>

A list to be searched.

Returns

ANY

Considerations

coll.min(null) returns null.

coll.min([]) returns null.

The minimum is determined using Cypher’s standard value ordering; see Equality, ordering, and comparison of value types.

Example 9. coll.min()
Query
RETURN coll.min([true, 'a', 1, 5.4])

The minimum value found in the given list based on Cypher’s ordering.

Result
coll.min([true, 'a', 1, 5.4])

true

Rows: 1

coll.remove()

Details

Syntax

coll.remove(list, index)

Description

Returns a list with the value at the given index removed.

Arguments

Name

Type

Description

list

LIST<ANY>

A list to remove a value from.

index

INTEGER

The index of the value to be removed.

Returns

LIST<ANY>

Considerations

Indexing is 0-based.

coll.remove(null, null) returns null.

coll.remove(null, index) returns null.

coll.remove(list, null) returns null.

If the given index is negative or larger than the size of the given list, an error is returned.

Example 10. coll.remove()
Query
RETURN coll.remove([true, 'a', 1, 5.4], 1)

The original list with the value at the given index removed and all values following shifted by 1.

Result
coll.remove([true, 'a', 1, 5.4], 1)

[true, 1, 5.4]

Rows: 1

coll.sort()

Details

Syntax

coll.sort(list)

Description

Returns a sorted list.

Arguments

Name

Type

Description

list

LIST<ANY>

A list to be sorted.

Returns

LIST<ANY>

Considerations

Sorting follows Cypher’s standard value ordering; see Equality, ordering, and comparison of value types.

coll.sort(null) returns null.

Example 11. coll.sort()
Query
RETURN coll.sort([true, 'a', 1, 2])

The list sorted using Cypher’s ordering in ascending order.

Result
coll.sort([true, 'a', 1, 2])

['a', true, 1, 2]

Rows: 1

coll.zip()

Details

Syntax

coll.zip(list1, list2, …​)

Description

Returns a list of lists formed by combining the elements at each index across two or more given lists.

Arguments

Name

Type

Description

list1

LIST<ANY>

The first list to zip.

list2

LIST<ANY>

The second list to zip.

…​

LIST<ANY>

Any additional lists to zip.

Returns

LIST<ANY>

Considerations

coll.zip() requires a minimum of two lists.

If any of the given lists is null, null is returned.

If the given lists are of different lengths, the missing values in the shorter lists are padded with null so that every inner list has the same length as the longest given list.

Example 12. coll.zip()
Zip two lists together
WITH [1, 2, 3] AS list1, ['a', 'b', 'c'] AS list2
RETURN coll.zip(list1, list2)

A LIST<ANY> containing a list for each pair of elements at the same index in the given lists is returned.

Result
coll.zip(list1, list2)

[[1, 'a'], [2, 'b'], [3, 'c']]

Rows: 1

Zip more than two lists together
WITH [1, 2] AS list1, ['a', 'b'] AS list2, [true, false] AS list3
RETURN coll.zip(list1, list2, list3)

More than two lists can be given.

Result
coll.zip(list1, list2, list3)

[[1, 'a', true], [2, 'b', false]]

Rows: 1

Zip lists of different lengths
WITH [1, 2, 3, 4] AS list1, ['a', 'b', 'c'] AS list2
RETURN coll.zip(list1, list2)

If the given lists are of different lengths, the missing values are padded with null.

Result
coll.zip(list1, list2)

[[1, 'a'], [2, 'b'], [3, 'c'], [4, null]]

Rows: 1

Zip with a null list
WITH [1, 2, 3] AS list1, null AS list2
RETURN coll.zip(list1, list2)

If any of the given lists is null, null is returned.

Result
coll.zip(list1, list2)

null

Rows: 1

keys()

Details

Syntax

keys(input)

Description

Returns a LIST<STRING> containing the STRING representations for all the property names of a NODE, RELATIONSHIP or MAP.

Arguments

Name

Type

Description

input

NODE | RELATIONSHIP | MAP

A node or relationship from which the names of all properties will be returned.

Returns

LIST<STRING>

Considerations

keys(null) returns null.

Example 13. keys()
Query
MATCH (a) WHERE a.name = 'Alice'
RETURN keys(a)

A LIST<STRING> containing the names of all the properties on the node bound to a is returned.

Result
keys(a)

["eyes", "name", "age"]

Rows: 1

labels()

Details

Syntax

labels(input)

Description

Returns a LIST<STRING> containing the STRING representations for all the labels of a NODE.

Arguments

Name

Type

Description

input

NODE

A node whose labels will be returned.

Returns

LIST<STRING>

Considerations

labels(null) returns null.

The order of the returned labels is not guaranteed when using the labels() function.

Example 14. labels()
Query
MATCH (a) WHERE a.name = 'Alice'
RETURN labels(a)

A LIST<STRING> containing all the labels of the node bound to a is returned.

Result
labels(a)

["Developer"]

Rows: 1

nodes()

Details

Syntax

nodes(input)

Description

Returns a LIST<NODE> containing all the NODE values in a PATH.

Arguments

Name

Type

Description

input

PATH

A path whose nodes will be returned.

Returns

LIST<NODE>

Considerations

The NODE values in the returned LIST are guaranteed to be in the exact order they appear along the path traversal, from the starting node to the end node.

nodes(null) returns null.

Example 15. nodes()
Query
MATCH p = (a)-->(b)-->(c)
WHERE a.name = 'Alice' AND c.name = 'Eskil'
RETURN nodes(p)

A LIST<NODE> containing all the nodes in the path p is returned.

Result
nodes(p)

[(:Developer {name: "Alice", eyes: "Brown", age: 38}), (:Administrator {name: "Bob", eyes: "Blue", age: 25}), (:Designer {name: "Eskil", likedColors: ["Pink", "Yellow", "Black"], eyes: "blue", age: 41})]

Rows: 1

range()

Details

Syntax

range(start, end [, step])

Description

Returns a LIST<INTEGER> comprising all INTEGER values within a specified range created with step length, optionally specifying a step length.

Arguments

Name

Type

Description

start

INTEGER

The start value of the range.

end

INTEGER

The end value of the range.

step

INTEGER

The size of the increment (default value: 1).

Returns

LIST<INTEGER>

Considerations

To create ranges with decreasing INTEGER values, use a negative value step.

The range is inclusive for non-empty ranges, and the arithmetic progression will therefore always contain start and — depending on the values of start, step and end — end. The only exception where the range does not contain start are empty ranges.

An empty range is returned when step is positive and start is greater than end, e.g. range(5, 0, 1), or when step is negative and start is less than end, e.g. range(0, 5, -1).

Example 16. range()
Query
RETURN range(0, 10), range(2, 18, 3), range(0, 5, -1)

Three lists of numbers in the given ranges are returned.

Result
range(0, 10) range(2, 18, 3) range(0, 5, -1)

[0,1,2,3,4,5,6,7,8,9,10]

[2,5,8,11,14,17]

[]

Rows: 1

reduce()

Details

Syntax

reduce(accumulator = initial, variable IN list | expression)

Description

Runs an expression against individual elements of a LIST<ANY>, storing the result of the expression in an accumulator.

Arguments

Name

Type

Description

accumulator

ANY

A variable that holds the result as the list is iterated. Starts with an initial value.

initial

ANY

The starting value of the accumulator.

variable

ANY

A variable that represents each element in the list during iteration.

list

LIST<ANY>

The list that is being iterated over.

expression

ANY

An expression that updates the accumulator with each iteration.

Returns

ANY

Considerations

reduce() differs from most Cypher functions because it iterates over a list, incrementally updating an accumulator with each element based on an expression, rather than returning a result from a single evaluation. As such, Cypher’s reduce() is analogous to the fold or reduce methods in functional languages such as Lisp and Scala.

Example 17. reduce()
Query
MATCH p = (a)-->(b)-->(c)
WHERE a.name = 'Alice' AND b.name = 'Bob' AND c.name = 'Daniel'
RETURN reduce(totalAge = 0, n IN nodes(p) | totalAge + n.age) AS reduction

The age property of all NODE values in the PATH are summed and returned as a single value.

Result
reduction

117

Rows: 1

relationships()

Details

Syntax

relationships(input)

Description

Returns a LIST<RELATIONSHIP> containing all the RELATIONSHIP values in a PATH.

Arguments

Name

Type

Description

input

PATH

The path from which all relationships will be returned.

Returns

LIST<RELATIONSHIP>

Considerations

relationships(null) returns null.

Example 18. relationships()
Query
MATCH p = (a)-->(b)-->(c)
WHERE a.name = 'Alice' AND c.name = 'Eskil'
RETURN relationships(p)

A LIST<RELATIONSHIP> containing all the RELATIONSHIP values in the PATH p is returned.

Result
relationships(p)

[[:KNOWS], [:MARRIED]]

Rows: 1

reverse()

Details

Syntax

reverse(input)

Description

Returns a STRING or LIST<ANY> in which the order of all characters or elements in the given STRING or LIST<ANY> have been reversed.

Arguments

Name

Type

Description

input

STRING | LIST<ANY>

The string or list to be reversed.

Returns

STRING | LIST<ANY>

Considerations

Any null element in original is preserved.

See also String functions → reverse().

Example 19. reverse()
Query
WITH [4923,'abc',521, null, 487] AS ids
RETURN reverse(ids)
Result
reverse(ids)

[487,<null>,521,"abc",4923]

Rows: 1

tail()

Details

Syntax

tail(input)

Description

Returns all but the first element in a LIST<ANY>.

Arguments

Name

Type

Description

input

LIST<ANY>

A list from which all but the first element will be returned.

Returns

LIST<ANY>

Example 20. tail()
Query
MATCH (a) WHERE a.name = 'Eskil'
RETURN a.likedColors, tail(a.likedColors)

The property named likedColors and a LIST<ANY> comprising all but the first element of the likedColors property are returned.

Result
a.likedColors tail(a.likedColors)

["Pink", "Yellow", "Black"]

["Yellow", "Black"]

Rows: 1

toBooleanList()

Details

Syntax

toBooleanList(input)

Description

Converts a LIST<ANY> of values to a LIST<BOOLEAN> values. If any values are not convertible to BOOLEAN they will be null in the LIST<BOOLEAN> returned.

Arguments

Name

Type

Description

input

LIST<ANY>

A list of values to be converted into a list of booleans.

Returns

LIST<BOOLEAN>

Considerations

Any null element in input is preserved.

Any BOOLEAN value in input is preserved.

If the input is null, null will be returned.

If the input is not a LIST<ANY>, an error will be returned.

The conversion for each value in input is done according to the toBooleanOrNull() function.

Example 21. toBooleanList()
Query
RETURN toBooleanList(null) as noList,
toBooleanList([null, null]) as nullsInList,
toBooleanList(['a string', true, 'false', null, ['A','B']]) as mixedList
Result
noList nullsInList mixedList

<null>

[<null>,<null>]

[<null>,true,false,<null>,<null>]

Rows: 1

toFloatList()

Details

Syntax

toFloatList(input)

Description

Converts a LIST<ANY> or a VECTOR to a LIST<FLOAT> values. If any values are not convertible to FLOAT they will be null in the LIST<FLOAT> returned.

Arguments

Name

Type

Description

input

VECTOR | LIST<ANY>

A list of values or a vector value to be converted into a list of floats.

Returns

LIST<FLOAT>

Considerations

Any null element in input is preserved.

Any FLOAT value in input is preserved.

If the input is null, null will be returned.

If the input is not a VECTOR or LIST<ANY>, an error will be returned.

input accepts VECTOR values as of Neo4j 2025.10

The conversion for each value in input is done according to the toFloatOrNull() function.

Example 22. toFloatList()
Query
RETURN toFloatList(null) as noList,
toFloatList([null, null]) as nullsInList,
toFloatList(['a string', 2.5, '3.14159', null, ['A','B']]) as mixedList
Result
noList nullsInList mixedList

<null>

[<null>,<null>]

[<null>,2.5,3.14159,<null>,<null>]

Rows: 1

toIntegerList()

Details

Syntax

toIntegerList(input)

Description

Converts a LIST<ANY> or a VECTOR to a LIST<INTEGER> values. If any values are not convertible to INTEGER they will be null in the LIST<INTEGER> returned.

Arguments

Name

Type

Description

input

VECTOR | LIST<ANY>

A list of values or a vector value to be converted into a list of integers.

Returns

LIST<INTEGER>

Considerations

Any null element in input is preserved.

Any INTEGER value in input is preserved.

If the input is null, null will be returned.

If the input is not a VECTOR or a LIST<ANY>, an error will be returned.

input accepts VECTOR values as of Neo4j 2025.10

The conversion for each value in list is done according to the toIntegerOrNull() function.

Example 23. toIntegerList()
Query
RETURN toIntegerList(null) as noList,
toIntegerList([null, null]) as nullsInList,
toIntegerList(['a string', 2, '5', null, ['A','B']]) as mixedList
Result
noList nullsInList mixedList

<null>

[<null>,<null>]

[<null>,2,5,<null>,<null>]

Rows: 1

toStringList()

Details

Syntax

toStringList(input)

Description

Converts a LIST<ANY> to a LIST<STRING> values.

Arguments

Name

Type

Description

input

LIST<ANY>

A list of values to be converted into a list of strings.

Returns

LIST<STRING>

Considerations

Any null element in input is preserved.

Any STRING value in input is preserved.

If the input is null, null will be returned.

If the input is not a LIST<ANY>, an error will be returned.

The conversion for each value in input is done according to the toStringOrNull() function.

Prior to Neo4j 2026.09, this function did not accept LIST, MAP, NODE, RELATIONSHIP, and PATH types.

Example 24. toStringList()
Query
RETURN toStringList(null) as noList,
toStringList([null, null]) as nullsInList,
toStringList(['already a string', 2, date({year:1955, month:11, day:5}), null, ['A','B']]) as mixedList
Result
noList nullsInList mixedList

NULL

["null", "null"]

["already a string", "2", "1955-11-05", "null", "[A, B]"]

Rows: 1