UUIDs

UUID values can be created and stored as properties on nodes and relationships.

The UUID type

The UUID type is a 128-bit identifier, commonly used to uniquely identify objects within a distributed system. In Cypher®, UUID values are stored as a dedicated type and can be represented as a hexadecimal string in the format 8-4-4-4-12 (e.g., 550e8400-e29b-41d4-a716-446655440000).

An example UUID value
uuid("550e8400-e29b-41d4-a716-446655440000")

In this example, the string "550e8400-e29b-41d4-a716-446655440000" is a valid representation of a UUID.

Cypher’s UUID type does not guarantee a specific UUID version. See the RFC 9562 Universally Unique IDentifiers (UUIDs) documentation for details on the different UUID versions.
You can convert UUID values into STRING values with the toString() function.

Valid values

A UUID value must follow the standard representation of 32 hexadecimal digits, displayed in five groups separated by hyphens (e.g., 8-4-4-4-12).

Construct UUID values

To construct a UUID value, use the uuid() function.

Example 1. Create a UUID value from a STRING value.
Query
RETURN uuid("550e8400-e29b-41d4-a716-446655440000") AS uuid
Result
uuid

uuid("550e8400-e29b-41d4-a716-446655440000")

Rows: 1

Example 2. Create a UUID value using parameters
Parameters (STRING)
{
  "uuidAsString": "550e8400-e29b-41d4-a716-446655440000"
}
Query
RETURN uuid($uuidAsString) AS uuid
Result
uuid

uuid("550e8400-e29b-41d4-a716-446655440000")

Rows: 1

Store UUID values as properties

To store a UUID value as a node or relationship property, use the uuid() function and a write clause.

Storing UUID values requires the database to use block format. This is the default on Aura instances. Community Edition cannot store UUID values as properties.
Example 3. Create a node with a UUID property
Query
CREATE (n:Label {uuidProp: uuid("550e8400-e29b-41d4-a716-446655440000")})
RETURN n.uuidProp AS uuidProp
Result
uuidProp

uuidProp("550e8400-e29b-41d4-a716-446655440000")

Rows: 1

Example 4. Create a node with a UUID property using parameters
Parameters
{
  "uuidString": "550e8400-e29b-41d4-a716-446655440000"
}
Query
CREATE (n:Label {uuidProp: uuid($uuidString)})
RETURN n.uuidProp AS uuidProp
Result
uuidProp

uuid("550e8400-e29b-41d4-a716-446655440000")

Rows: 1

UUIDs and client libraries (drivers)

Working with uuids via Neo4j’s client libraries results in a different behavior depending on the library version.

  • Versions >= 6.2 — UUIDs are fully supported and mapped into client types (see the Data types page of each language manual).

  • Versions < 6.2 — UUIDs can be created, attached, and manipulated in queries via Cypher functions, but cannot be returned nor created in the application.
    It is possible to create and store values as shown in the Store UUID values as properties examples, but returning a UUID results in a placeholder MAP value and a warning.

    Result of returning a UUID with a driver older than 6.2
    +------------------------------------------------------------------------------------------------------+
    | n.uuid                                                                                               |
    +------------------------------------------------------------------------------------------------------+
    | {originalType: "UUID("550e8400-e29b-41d4-a716-446655440000")", reason: "UNKNOWN_TYPE"}               |
    +------------------------------------------------------------------------------------------------------+
    warn: One or more values returned could not be handled by this version of the driver and were replaced with placeholder map values. Please upgrade your driver!
    03N95 (Neo.ClientNotification.UnknownType)