# How to Export Knowledge Graphs to RDF, OWL, Parquet, and Cypher Formats with Semantica

> Export knowledge graphs to RDF, OWL, Parquet, and Cypher with Semantica's modular framework. Learn how to convert your data into various formats easily.

- Repository: [Semantica /semantica](https://github.com/semantica-agi/semantica)
- Tags: how-to-guide
- Published: 2026-08-20

---

**Semantica provides a modular export framework that converts knowledge graphs into RDF (including OWL), Parquet, and Cypher formats through specialized exporter classes registered in [`semantica/export/methods.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/export/methods.py).**

The `semantica-agi/semantica` repository implements a comprehensive export system that enables seamless conversion of knowledge graphs into industry-standard formats. Whether you need semantic web compatibility via RDF/OWL, analytical performance with Parquet, or graph database imports via Cypher, the library offers dedicated exporters with validation and serialization capabilities.

## Understanding the Export Architecture

Semantica's export system follows a modular design that isolates format-specific logic into dedicated classes. The architecture centers on three primary exporters: **`RDFExporter`** for semantic web formats, **`ParquetExporter`** for columnar analytics, and **`LPGExporter`** for labeled property graphs.

All exporters integrate with the **MCP tool** `export_graph` defined in [`mcp/tools/export.py`](https://github.com/semantica-agi/semantica/blob/main/mcp/tools/export.py) (lines 24-88), which examines the `format` argument and routes to the appropriate implementation. For programmatic access, the high-level convenience function `export_knowledge_graph` in [`semantica/export/methods.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/export/methods.py) (lines 865-902) abstracts this dispatch logic, allowing you to specify the target format with a single parameter.

## Exporting to RDF and OWL Formats

The **`RDFExporter`** class in [`semantica/export/rdf_exporter.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/export/rdf_exporter.py) (lines 910-965) handles serialization to multiple RDF formats, including OWL ontologies. It manages namespaces through `NamespaceManager`, validates output via `RDFValidator`, and serializes through `RDFSerializer`.

Supported formats include **Turtle**, **RDF/XML**, **JSON-LD**, **N-Triples**, and **N3**. OWL ontologies are typically exported using RDF/XML or Turtle syntax, as OWL is an RDF vocabulary.

```python
from semantica.export import RDFExporter

kg = {
    "entities": [
        {"id": "E1", "type": "Person", "name": "Alice"},
        {"id": "E2", "type": "City", "name": "Wonderland"},
    ],
    "relationships": [
        {"source_id": "E1", "target_id": "E2", "type": "LIVES_IN"}
    ],
}

rdf_exporter = RDFExporter()
turtle_str = rdf_exporter.export_to_rdf(kg, format="turtle")
print(turtle_str)

```

The exporter returns a string representation for text-based formats or writes directly to file paths for persistence.

## Exporting to Parquet for Analytics

The **`ParquetExporter`** class in [`semantica/export/parquet_exporter.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/export/parquet_exporter.py) (lines 93-115) converts knowledge graphs into Apache Parquet format using explicit **Arrow schemas** for entities and relationships. This format supports analytical workloads with efficient columnar compression.

The exporter handles both single-file and multi-file exports, utilizing compression codecs such as **snappy** and **gzip**. It generates separate Parquet files for entities and relationships within a specified directory structure.

```python
from semantica.export import ParquetExporter

parquet_exporter = ParquetExporter(compression="gzip")
parquet_exporter.export_knowledge_graph(kg, "kg_parquet")

```

This creates `kg_parquet/entities.parquet` and `kg_parquet/relationships.parquet`, ready for ingestion into dataframes or analytics pipelines.

## Exporting to Cypher for Graph Databases

The **`LPGExporter`** class in [`semantica/export/lpg_exporter.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/export/lpg_exporter.py) (lines 32-50) generates **Cypher** `CREATE` statements for importing knowledge graphs into Neo4j, Memgraph, or other labeled property graph databases.

The exporter sanitizes properties, batches statements according to the `batch_size` parameter (default 500), and optionally emits indexes and constraints. The output is a `.cypher` script file that executes directly in graph database consoles.

```python
from semantica.export import LPGExporter

lpg_exporter = LPGExporter(batch_size=500)
lpg_exporter.export_knowledge_graph(kg, "kg.cypher")

```

## Unified Export API

### The export_knowledge_graph Convenience Function

Rather than instantiating exporters directly, use the **`export_knowledge_graph`** function in [`semantica/export/methods.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/export/methods.py) (lines 865-902). This dispatcher automatically selects the correct exporter based on the `format` parameter and handles file path resolution.

```python
from semantica.export.methods import export_knowledge_graph

# RDF formats (includes OWL-compatible Turtle)

export_knowledge_graph(kg, "my_graph.ttl", format="turtle")

# Parquet directory

export_knowledge_graph(kg, "my_graph_parquet", format="parquet")

# Cypher script

export_knowledge_graph(kg, "my_graph.cypher", format="cypher")

```

### MCP Tool Integration

For AI-assisted workflows, the **`export_graph`** tool in [`mcp/tools/export.py`](https://github.com/semantica-agi/semantica/blob/main/mcp/tools/export.py) (lines 24-88) exposes these capabilities through the Model Context Protocol. The tool accepts a `format` argument and returns either a string payload for text formats or a file path for binary outputs like Parquet and Cypher.

## Summary

Semantica's export framework provides specialized pathways for persisting knowledge graphs across diverse ecosystems:

- **RDFExporter** ([`semantica/export/rdf_exporter.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/export/rdf_exporter.py)) serializes to Turtle, RDF/XML, JSON-LD, and OWL-compatible formats with namespace management and validation.
- **ParquetExporter** ([`semantica/export/parquet_exporter.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/export/parquet_exporter.py)) creates compressed, columnar Arrow schemas optimized for analytics workflows.
- **LPGExporter** ([`semantica/export/lpg_exporter.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/export/lpg_exporter.py)) generates executable Cypher scripts with batched `CREATE` statements for Neo4j and compatible databases.
- **Unified API** ([`semantica/export/methods.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/export/methods.py)) and **MCP integration** ([`mcp/tools/export.py`](https://github.com/semantica-agi/semantica/blob/main/mcp/tools/export.py)) provide single-call access to all formats with automatic exporter selection.

## Frequently Asked Questions

### Can Semantica export knowledge graphs to OWL format?

Yes. OWL ontologies are supported through the **`RDFExporter`** class using RDF/XML or Turtle serializations. Since OWL is an RDF vocabulary, you can export OWL-encoded knowledge graphs by specifying `format="xml"` or `format="turtle"` when calling `export_to_rdf()` or the high-level `export_knowledge_graph()` function.

### What compression codecs does ParquetExporter support?

The **`ParquetExporter`** class supports standard Arrow compression codecs including **snappy**, **gzip**, **brotli**, and **zstd**. You specify the codec via the `compression` parameter during instantiation, as implemented in [`semantica/export/parquet_exporter.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/export/parquet_exporter.py) (lines 93-115).

### How do I choose between single-file and multi-file Parquet exports?

The **`ParquetExporter`** automatically handles multi-file exports by creating separate Parquet files for entities and relationships within your specified directory. When you provide a directory path like `"kg_output"`, it generates `entities.parquet` and `relationships.parquet` rather than a single consolidated file, optimizing for analytical query patterns that typically access entities and relationships separately.

### Does the Cypher export support specific graph databases like Neo4j?

Yes. The **`LPGExporter`** generates standard Cypher `CREATE` statements compatible with **Neo4j**, **Memgraph**, and other labeled property graph databases that implement the openCypher specification. The exporter optionally includes indexes and constraints specific to your graph schema, producing `.cypher` scripts that import directly into Neo4j's Browser or `cypher-shell` without modification.