Cypher Query Language is a declarative, ASCII-art-based language specifically designed for querying and manipulating property graph data. It allows users to express complex graph patterns intuitively by describing the visual structure of nodes, relationships, and their properties they wish to find or create. Its syntax is built around the core concept of pattern matching, making it highly readable for developers familiar with graph concepts. Cypher is the native query language for the Neo4j graph database and has influenced the open openCypher project and the GQL international standard.
Glossary
Cypher Query Language

What is Cypher Query Language?
Cypher is the declarative, pattern-matching query language for property graph databases, most notably Neo4j.
Cypher operates on a labeled property graph model, where nodes (entities) and relationships (connections) can have labels and key-value properties. A query describes a pattern, such as (p:Person)-[:LIVES_IN]->(c:City), which the database engine matches against the stored graph. It supports standard CRUD operations, aggregation, filtering, and pathfinding. For enterprise use, Cypher integrates with ACID transactions, index-free adjacency for fast traversals, and is a core component of Knowledge Graph as a Service platforms, enabling deterministic querying of interconnected business data.
Key Features of Cypher
Cypher is a declarative, ASCII-art-inspired query language for property graph databases. Its core strength lies in intuitively expressing graph patterns to find, create, update, and delete data.
Declarative Pattern Matching
Cypher is a declarative language, meaning you describe what data you want, not how to retrieve it. You define patterns using an intuitive ASCII-art syntax.
- Example:
(p:Person)-[:LIVES_IN]->(c:City)finds allPersonnodes connected toCitynodes via aLIVES_INrelationship. - The engine's query optimizer determines the most efficient execution plan, abstracting traversal logic from the developer.
Property Graph Model
Cypher is designed for the property graph model, where both nodes (entities) and relationships (connections) can have properties (key-value pairs).
- Nodes are represented in parentheses:
(:Person {name: 'Alice', age: 30}). - Relationships use brackets and arrows:
-[:WORKS_AT {since: 2020}]->. - This model allows for a rich, schema-flexible representation of connected data, closely mirroring real-world domains.
Clauses for Data Manipulation
Cypher uses a structured set of clauses to compose queries, similar to SQL.
- MATCH: Locates patterns in the graph.
- WHERE: Filters results with predicates.
- RETURN: Specifies what data to output.
- CREATE / MERGE: Inserts new data or ensures it exists.
- SET / REMOVE: Updates or deletes properties.
- DELETE: Removes nodes and relationships.
- WITH: Pipes results between query parts, enabling complex multi-step operations.
Path Queries & Variable-Length Traversals
A core capability is querying for paths—sequences of nodes and relationships. Cypher excels at variable-length traversals to discover connections of unknown depth.
- Use
*for variable hops:(:Person)-[:KNOWS*1..5]->(:Person)finds chains ofKNOWSrelationships between 1 and 5 hops long. - The shortestPath() function finds the optimal path between two nodes.
- This is essential for recommendation systems, fraud detection (finding rings), and network analysis.
Aggregations & Graph Analytics
Cypher supports powerful aggregation functions and collection operations for analytical workloads directly on the graph structure.
- Use
COUNT(),SUM(),COLLECT()in aRETURNclause withGROUP BY. - Built-in graph algorithms like PageRank and Louvain community detection can be invoked via Cypher procedures (e.g.,
CALL gds.pageRank.stream). - This enables business intelligence and graph data science without exporting data to external systems.
Index-Free Adjacency & Performance
Cypher queries are optimized for index-free adjacency, a native graph storage paradigm where nodes hold direct pointers to connected relationships. This enables constant-time traversals regardless of total graph size.
- Query planners use statistical metadata to select optimal start nodes and traversal directions.
- Composite indexes and full-text indexes accelerate property lookups.
- Query caching and parameterization (
$param) improve throughput for repeated query patterns.
How Cypher Works: Pattern Matching
Cypher is a declarative, ASCII-art-inspired query language designed specifically for property graph databases, allowing users to express complex graph patterns intuitively.
Cypher works by allowing users to describe graph patterns using a visual, ASCII-art syntax where parentheses () represent nodes, arrows --> or -- represent relationships, and square brackets [] can hold relationship details. The core operation is pattern matching, where the query engine searches the graph for all subgraphs that conform to the specified pattern. This declarative approach abstracts away the procedural steps of traversal, letting users focus on what data to find, not how to find it. For example, (p:Person)-[:LIVES_IN]->(c:City) matches all person nodes connected to city nodes via a LIVES_IN relationship.
The language's power comes from combining these patterns with clauses like MATCH (to find patterns), WHERE (to filter results), RETURN (to project data), and CREATE (to insert data). Its design enables index-free adjacency lookups, where traversing from one node to its connected nodes is a constant-time operation. This makes Cypher exceptionally efficient for exploring deep, connected data, forming the foundation for graph-based RAG and complex relationship discovery in enterprise knowledge graphs without requiring complex joins.
Cypher vs. SQL vs. SPARQL
A feature comparison of three declarative query languages designed for different underlying data models: property graphs, relational tables, and RDF graphs.
| Feature / Paradigm | Cypher | SQL | SPARQL |
|---|---|---|---|
Primary Data Model | Property Graph (Nodes, Relationships, Properties) | Relational (Tables, Rows, Columns) | RDF Graph (Subject-Predicate-Object Triples) |
Core Query Construct | Graph Pattern Matching (ASCII-art syntax) | Table Selection and Joins (SELECT ... FROM ... WHERE) | Graph Pattern Matching (Triple pattern syntax) |
Schema Flexibility | Schema-optional (labels & types provide structure) | Schema-required (strict table definitions) | Schema-flexible (ontology provides optional constraints) |
Path Query Support | Native, declarative path patterns with variable length | Requires recursive common table expressions (CTEs) | Native via property paths in SPARQL 1.1 |
Aggregation & Grouping | Supported (e.g., COUNT, COLLECT, GROUP BY) | Extensive, mature support | Supported (e.g., COUNT, GROUP BY) |
Inference & Reasoning | Limited to path expansion; no built-in logical reasoner | None (purely based on stored data) | Native via entailment regimes (e.g., OWL 2 RL, RDFS) |
Federated Query Support | Limited; typically vendor-specific | Extensive (via database links, FDWs) | Native in SPARQL 1.1 (SERVICE clause) |
Primary Use Case | Navigating connected data, fraud detection, recommendations | Transactional reporting, aggregating columnar data | Integrating heterogeneous data, semantic web, linked data |
Where is Cypher Used?
Cypher is the native query language for Neo4j and is supported by several other graph systems. Its primary application is querying and manipulating property graph data across diverse enterprise domains.
Graph Analytics & Business Intelligence
Cypher is used to power graph-based analytics, uncovering insights through relationship-centric queries that are cumbersome in SQL.
- Fraud Detection: Find complex rings of connected entities (e.g.,
(p1:Person)-[:TRANSFERRED_TO*3..5]->(p2:Person)). - Recommendation Engines: Query for paths between users and products ("People who bought X also bought Y").
- Supply Chain Analysis: Traverse supplier networks to identify single points of failure or optimize routes.
- Social Network Analysis: Calculate centrality metrics (PageRank, betweenness) using built-in or user-defined procedures.
Knowledge Graph Querying & Reasoning
Within Enterprise Knowledge Graphs, Cypher is used to query interconnected entities and their properties, serving as a foundational layer for deterministic reasoning.
- Semantic Search: Traverse ontology-based relationships to answer complex questions (e.g., "Which projects use deprecated libraries?").
- Data Lineage & Provenance: Trace the origin and transformation of data assets through explicit relationship chains.
- Graph-Based RAG: Retrieve precise subgraphs as context for LLMs, providing factual grounding and eliminating hallucinations. Cypher queries fetch connected facts, not just isolated chunks.
Application Backends & Microservices
Cypher is executed from within application code via official drivers, making it the interface between business logic and the graph data layer.
- Official Drivers: Use Neo4j drivers for Java, JavaScript, Python, .NET, and Go to send parameterized Cypher queries.
- Parameterized Queries: Prevent injection attacks and enable query reuse (e.g.,
MATCH (p:Person {name: $name})). - Transaction Management: Group multiple Cypher operations within ACID transactions to ensure data integrity.
- Microservice Integration: A dedicated graph microservice often exposes endpoints that execute specific Cypher queries to serve graph data to other services.
Data Science & Machine Learning Workflows
Data scientists use Cypher to extract connected datasets for feature engineering and to operationalize graph-native ML models.
- Feature Extraction: Query subgraphs around entities to create predictive features (e.g., a customer's network influence).
- Graph Algorithm Execution: Call Graph Algorithm Library functions (like Louvain community detection) via Cypher procedures (
CALL gds.louvain.stream). - Graph Embedding Generation: Use Cypher to project a graph and feed it into a Graph Neural Network (GNN) Service.
- Link Prediction: Write Cypher queries to find candidate pairs for relationship prediction models.
Frequently Asked Questions
Cypher is the declarative query language for property graph databases, designed for intuitive pattern matching. These FAQs address its core mechanics, use cases, and how it compares to other graph query languages.
Cypher is a declarative, pattern-matching query language specifically designed for querying and manipulating property graph databases. It works by allowing users to describe visual patterns of nodes and relationships using an ASCII-art syntax, which the database's query engine then matches against the stored graph structure. For example, the query MATCH (p:Person)-[:LIVES_IN]->(c:City) RETURN p.name, c.name finds all Person nodes connected to City nodes via a LIVES_IN relationship and returns their names. The engine optimizes and executes this pattern, traversing the graph's inherent index-free adjacency for high-performance lookups.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Cypher is a declarative graph query language for the Neo4j property graph database. Understanding its ecosystem requires familiarity with related data models, query languages, and architectural components.
Property Graph
The underlying data model for Cypher. A property graph consists of:
- Nodes: Represent entities (e.g., a
Person,Product). - Relationships: Represent directed connections between nodes (e.g.,
PURCHASED). - Properties: Key-value pairs attached to both nodes and relationships (e.g.,
name: 'Alice'). - Labels: Types or categories assigned to nodes (e.g.,
:Customer). Cypher's pattern-matching syntax is designed to traverse this model intuitively.
Gremlin Traversal
An imperative, step-by-step graph traversal language, contrasting with Cypher's declarative style. Part of the Apache TinkerPop framework, Gremlin is used to query both property graphs and RDF graphs. While Cypher expresses what to find, Gremlin specifies how to walk the graph. It is supported by databases like Amazon Neptune and Azure Cosmos DB.
SPARQL
The standard query language for RDF triplestores and the semantic web. Unlike Cypher's property graph model, SPARQL queries data structured as subject-predicate-object triples. It is used for querying knowledge graphs built on W3C standards (RDF, OWL) and is supported by endpoints in systems like Amazon Neptune and Stardog.
Index-Free Adjacency
A core storage optimization in native graph databases like Neo4j that enables Cypher's performance. Instead of using global indexes to find connected nodes, each node stores physical pointers to its adjacent relationships and nodes. This allows traversals to proceed at constant time O(1) speed, regardless of total graph size, by following these stored pointers.
Graph Query Optimization
The set of techniques used by the database engine to efficiently execute Cypher queries. This includes:
- Cost-based query planning to select the optimal traversal order.
- Index utilization for fast node lookup by label and property.
- Query caching of frequent patterns.
- Parallel execution of query parts. Understanding these helps diagnose and improve slow Cypher queries.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us