Scalar functions
Wiki / Cypher query language
On this page
String functions
| Function | Description | Example → result |
toUpper(s) | Uppercase | toUpper('ada') → 'ADA' |
toLower(s) | Lowercase | toLower('ADA') → 'ada' |
trim(s) | Strip leading+trailing whitespace | trim(' x ') → 'x' |
ltrim(s) | Strip leading whitespace | ltrim(' x ') → 'x ' |
rtrim(s) | Strip trailing whitespace | rtrim(' x ') → ' x' |
substring(s, start[, len]) | Substring from start (0-based), optional length | substring('graph', 1, 3) → 'rap' |
replace(s, search, repl) | Replace all occurrences | replace('a.b.c', '.', '-') → 'a-b-c' |
split(s, delim) | Split into a list of strings | split('a,b,c', ',') → ['a','b','c'] |
left(s, n) | First n characters | left('graph', 2) → 'gr' |
right(s, n) | Last n characters | right('graph', 2) → 'ph' |
reverse(s) | Reverse a string (also works on lists) | reverse('abc') → 'cba' |
toString(x) | Render supported scalars and spatial/temporal values; lists/maps/bytes error | toString(42) → '42' |
Type-conversion functions
| Function | Description | Notes |
toInteger(x) | Convert to integer | integer strings and floats accepted; invalid strings return null, unsupported types error |
toFloat(x) | Convert numbers or numeric strings | invalid strings return null; unsupported types error |
toBoolean(x) | Convert to boolean | 'true'/'false' (case-insensitive) → bool |
toString(x) | Convert to string | see above |
RETURN toInteger('42') AS i, toFloat('3.14') AS f, toBoolean('TRUE') AS b;
Numeric functions
| Function | Description | Example → result |
abs(x) | Absolute value (int or float) | abs(-5) → 5 |
ceil(x) | Round up (→ float) | ceil(2.1) → 3.0 |
floor(x) | Round down (→ float) | floor(2.9) → 2.0 |
round(x) | Round to nearest (→ float) | round(2.5) → 3.0 |
sqrt(x) | Square root | sqrt(9) → 3.0 |
sign(x) | Sign: -1, 0, or 1 | sign(-7) → -1 |
range(start, end[, step]) | List of integers start..=end | range(1, 5) → [1,2,3,4,5] |
UNWIND range(1, 5) AS x RETURN x, x * x AS square;
List functions
| Function | Description | Example → result |
size(x) | Length of a list/string; use size(keys(map)) for maps | size([1,2,3]) → 3 |
head(list) | First element (or null) | head([10,20]) → 10 |
last(list) | Last element (or null) | last([10,20]) → 20 |
tail(list) | All but the first element | tail([10,20,30]) → [20,30] |
reverse(list) | Reverse | reverse([1,2,3]) → [3,2,1] |
range(a, b[, step]) | Integer list (see numeric) | |
(List indexing l[i] and slicing l[a..b] are operators — see
Operators and expressions.)
Null-handling
| Function | Description |
coalesce(a, b, …) | First non-null argument; null if all are null. Does not null-propagate. |
MATCH (p:Person) RETURN coalesce(p.nick, p.name, 'anonymous') AS display;
Graph / entity functions
| Function | Description |
id(e) | Internal integer id of a node or relationship |
elementId(e) | String form of the internal integer id; not stable across deletion/reuse |
labels(n) | List of a node's labels |
type(r) | A relationship's type (string) |
keys(e) | List of an entity's (or map's) property keys |
properties(e) | The entity's properties as a map |
nodes(p) | The nodes of a path p, in order |
relationships(p) | The relationships of a path p, in order |
length(p) | Number of relationships in a path p |
MATCH p = (a:Person {name: 'Ada'})-[:KNOWS*1..3]->(b)
RETURN b.name, length(p), [n IN nodes(p) | n.name] AS chain;
List and pattern comprehensions are supported; see comprehensions.
MATCH (n) RETURN id(n), labels(n), keys(n), properties(n) LIMIT 5;
MATCH ()-[r]->() RETURN type(r) LIMIT 5;
Spatial & temporal constructors
| Function | Description | See |
point({...}) | Construct a Point (cartesian or WGS-84) | Spatial points |
distance(a, b) / point.distance(a, b) | Distance between two points | Spatial points |
spatial.fromWKT, spatial.fromWKB, spatial.fromGeoJSON | Strict geometry/geography constructors | Formats and drivers |
spatial.intersects, spatial.contains, spatial.covers and other predicates | Test shape relationships | Predicates and overlays |
spatial.union, spatial.intersection, spatial.difference, spatial.symDifference, spatial.clip, spatial.identity | Combine, cut or partition shapes | Predicates and overlays |
spatial.centroid | Weighted centre, retaining domain and SRID | Centroid |
datetime(...) | Construct/parse/re-zone a zoned DateTime | Temporal values and time zones |
date(...) | Construct/parse a DATE; truncates a (local)datetime value or string (no arg = today, UTC) | Temporal values and time zones |
localtime(...) / time(...) | A local / zoned time-of-day | Temporal values and time zones |
localdatetime(...) | A zoneless date-time | Temporal values and time zones |
duration(...) | Construct/parse a DURATION (ISO-8601 or a component map) | Temporal values and time zones |
duration.between(a, b) | The duration between two temporals | Temporal values and time zones |
Point and temporal fields are read by access syntax, not functions:
p.x, p.y, p.z, p.longitude, p.latitude, p.height, p.srid, p.crs;
dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second,
dt.nanosecond, dt.epochSeconds, dt.epochMillis, dt.offsetSeconds,
dt.offset, dt.timezone; a DURATION's .years, .months, .days, .hours,
.minutes, .seconds, .milliseconds, .nanoseconds.
range includes both endpoints, accepts a negative step for descending ranges,
and rejects a zero step. For example, RETURN range(5, 1, -2) returns [5,3,1].
See aggregates for row-level grouping and
APOC scalar functions for additional collection operations.
Related articles
Indexes and constraints · Procedure directory · Transactions and concurrency