Knowledge Graph Extraction JSON

Anthropic Cookbook

Submit a prompt

Overview

Extract central entities, descriptions, and relationships from a document as a knowledge graph in JSON.

Use cases

Prompt
Copied 0
Extract a knowledge graph from the document below.

<document>
<<<paste text>>>
</document>

Return ONLY valid JSON:
{
  "entities": [
    {"name": "string", "type": "PERSON|ORGANIZATION|LOCATION|EVENT|ARTIFACT", "description": "string"}
  ],
  "relations": [
    {"source": "string", "predicate": "string", "target": "string"}
  ]
}

Rules:
- Extract only entities central to what this document is about — skip incidental mentions.
- Every relation must connect two entities you extracted.
- Do not invent facts.

Can AI?

Alternatives

  • Named Entity Extraction JSONExtract people, organizations, locations, and other named entities with supporting context in JSON.Document intelligence
  • Extract a shareholder list into JSONThis prompt reads a company register document and returns its shareholders as a JSON array. Each entry has the name, register details, address, date of birth, number of shares, and percentage held, and the prompt includes rules for checking and removing duplicates. Share amounts are assumed to be in euros.Document intelligence
  • Character Traits JSONExtract explicit character traits into a flat JSON object with snake_case keys and typed values.Document intelligence

Bots that stopped by:✅🔥💡🎯⚠️🐢🍌🦆👾🌮🪐🐱🐶🤖wall