Knowledge Graph - Json To Triples Converter
/install json-to-triples-converter
JSON to Triples Converter
Transform JSON documents into RDF triples and graph-ready structures.
This skill converts hierarchical JSON data into subject–predicate–object triples, enabling the data to be ingested into knowledge graphs, semantic web systems, and graph databases. The generated triples can be exported in multiple formats including RDF Turtle, N-Triples, JSON-LD, and Graph JSON.
Quick Start
Use When
- Converting JSON datasets to RDF triples
- Transforming JSON APIs into knowledge graphs
- Creating semantic web representations from JSON
- Building linked data from structured JSON
- Converting JSON to JSON-LD for semantic markup
- Preparing JSON for graph database ingestion
- Extracting semantic relationships from JSON
Inputs
- JSON documents or data structures
- Entity type specifications
- Property-to-predicate mappings
- Namespace/URI definitions
- Output format preferences
- Custom mapping rules
- Vocabulary specifications (schema.org, FOAF, etc.)
Outputs
- RDF Turtle triples
- N-Triples format
- JSON-LD documents
- Graph JSON (nodes/edges)
- Property graph structures
- Semantic metadata
- URI mappings
Example
Input JSON:
{
"person": {
"name": "Alice",
"age": 30,
"email": "[email protected]",
"company": {
"name": "Acme Corp",
"industry": "Technology"
}
}
}
Generated RDF Triples (Turtle):
@prefix ex: \x3Chttp://example.org/> .
@prefix foaf: \x3Chttp://xmlns.com/foaf/0.1/> .
@prefix schema: \x3Chttp://schema.org/> .
ex:person_alice a foaf:Person ;
foaf:name "Alice" ;
foaf:age 30 ;
foaf:mbox "[email protected]" ;
schema:worksFor ex:company_acme .
ex:company_acme a schema:Organization ;
foaf:name "Acme Corp" ;
schema:industry "Technology" .
JSON-to-Triples Conversion Strategy
1. JSON Structure Analysis
Analyze the JSON document to understand:
- Root entities (objects)
- Entity properties (keys)
- Nested relationships (nested objects)
- Arrays and collections
- Data types and literals
2. Entity Identification
Detect entities that represent real-world objects:
- Person - Individual entities
- Organization - Companies, groups
- Product - Items, goods
- Location - Places, regions
- Event - Occurrences, activities
- Custom - Domain-specific entities
3. Subject Generation
Create unique URIs for each entity:
Person "Alice" → ex:person_alice
Company "Acme" → ex:company_acme
Location "New York" → ex:location_newyork
4. Predicate Mapping
Map JSON keys to RDF predicates:
"name" → foaf:name
"age" → foaf:age
"worksFor" → schema:worksFor
"email" → foaf:mbox
5. Object Generation
Generate appropriate object values:
Literal values: "Alice", 30, true
References: ex:company_acme (URI reference)
Typed literals: "2024-04-09"^^xsd:date
6. Relationship Extraction
Convert nested objects to relationships:
{
"employee": {
"name": "Alice",
"manager": {
"name": "Bob"
}
}
}
Becomes:
ex:employee_alice schema:manager ex:person_bob .
7. Deduplication
Ensure shared entities are represented once:
- Same entity referenced multiple times → Single URI
- Identical values → Deduplicated
- Entity linking across documents
Conversion Patterns
Simple Property Mapping
{"name": "Alice", "age": 30}
↓
ex:subject foaf:name "Alice" .
ex:subject foaf:age 30 .
Nested Object Pattern
{"person": {"name": "Alice", "company": {"name": "Acme"}}}
↓
ex:person_alice foaf:name "Alice" .
ex:person_alice ex:worksAt ex:company_acme .
ex:company_acme foaf:name "Acme" .
Array/Collection Pattern
{"tags": ["python", "graph", "rdf"]}
↓
ex:subject ex:tag "python" .
ex:subject ex:tag "graph" .
ex:subject ex:tag "rdf" .
Type Inference Pattern
{"age": 30, "created": "2024-04-09"}
↓
ex:subject foaf:age "30"^^xsd:integer .
ex:subject schema:dateCreated "2024-04-09"^^xsd:date .
Output Formats
RDF Turtle Format
@prefix ex: \x3Chttp://example.org/> .
@prefix foaf: \x3Chttp://xmlns.com/foaf/0.1/> .
ex:subject foaf:name "Alice" .
ex:subject foaf:age 30 .
ex:subject foaf:workplaceHomepage ex:company .
N-Triples Format
\x3Chttp://example.org/subject> \x3Chttp://xmlns.com/foaf/0.1/name> "Alice" .
\x3Chttp://example.org/subject> \x3Chttp://xmlns.com/foaf/0.1/age> "30"^^\x3Chttp://www.w3.org/2001/XMLSchema#integer> .
JSON-LD Format
{
"@context": {
"@vocab": "http://schema.org/",
"foaf": "http://xmlns.com/foaf/0.1/"
},
"@type": "Person",
"@id": "http://example.org/subject",
"foaf:name": "Alice",
"foaf:age": 30
}
Graph JSON Format
{
"nodes": [
{"id": "person_alice", "type": "Person", "properties": {"name": "Alice", "age": 30}},
{"id": "company_acme", "type": "Organization", "properties": {"name": "Acme"}}
],
"edges": [
{"source": "person_alice", "target": "company_acme", "type": "worksFor"}
]
}
Namespace Management
Standard Vocabularies
foaf: http://xmlns.com/foaf/0.1/
schema: http://schema.org/
rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs: http://www.w3.org/2000/01/rdf-schema#
owl: http://www.w3.org/2002/07/owl#
xsd: http://www.w3.org/2001/XMLSchema#
dbo: http://dbpedia.org/ontology/
Custom Namespaces
namespaces:
ex: http://example.org/
myapp: http://myapp.example.org/
custom: http://custom.vocabulary.org/
Data Type Inference
Type Detection
String values → xsd:string
Numbers (integer) → xsd:integer
Numbers (float) → xsd:decimal
Booleans → xsd:boolean
ISO dates → xsd:date / xsd:dateTime
URIs → xsd:anyURI
Literal Language Tags
{"title": {"en": "Alice", "fr": "Aline"}}
↓
ex:subject rdfs:label "Alice"@en .
ex:subject rdfs:label "Aline"@fr .
Execution Steps
- Parse JSON – Load and validate JSON structure
- Infer Schema – Detect entities and relationships
- Generate URIs – Create unique identifiers for entities
- Build Triples – Generate subject-predicate-object statements
- Manage Namespaces – Apply namespace prefixes
- Deduplicate – Remove duplicate entities
- Validate Output – Check triple validity
- Format Output – Generate desired output format
Recommended Libraries
- RDF Processing: rdflib, oxrdflib, pyld
- JSON Processing: json, jsonld, python-jsonld
- Validation: rdflib.plugins.sparql, owlready2
- URI Management: URIRef, Namespace
- Schema.org: schema, schema-org
- Data Type Handling: xsd, dateutil
Best Practices
✓ Use consistent namespace URIs
✓ Generate meaningful entity identifiers
✓ Normalize entity names to prevent duplicates
✓ Use standard vocabularies (schema.org, FOAF)
✓ Include language tags for multilingual content
✓ Type literal values appropriately
✓ Document custom vocabulary mappings
✓ Validate triples before output
✓ Handle nested structures recursively
✓ Manage URIs consistently
Integration with Downstream Skills
The generated triples feed into:
- Graph Constraint Generator – Define constraints on triple data
- Graph Schema Validation – Validate against RDF schemas
- Graph Query Optimization – Optimize SPARQL queries
- Knowledge Graph Construction – Build KGs from triples
- ETL Pipeline Generator – Orchestrate conversion workflows
References
See conversion-patterns.md for detailed JSON-to-triples conversion patterns and example-conversions.md for complete real-world examples.
Version: 1.0.0
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install json-to-triples-converter - 安装完成后,直接呼叫该 Skill 的名称或使用
/json-to-triples-converter触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Knowledge Graph - Json To Triples Converter 是什么?
Convert JSON documents into RDF triples or graph-ready subject–predicate–object statements for knowledge graphs and semantic databases. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 38 次。
如何安装 Knowledge Graph - Json To Triples Converter?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install json-to-triples-converter」即可一键安装,无需额外配置。
Knowledge Graph - Json To Triples Converter 是免费的吗?
是的,Knowledge Graph - Json To Triples Converter 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Knowledge Graph - Json To Triples Converter 支持哪些平台?
Knowledge Graph - Json To Triples Converter 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Knowledge Graph - Json To Triples Converter?
由 Muhammad Asif(@fisa712)开发并维护,当前版本 v1.0.0。