Appearance
Token Efficiency
FreshHow MD-LD compares to JSON-LD and Turtle in LLM token consumption — measured across two tokenizers, seven graph structures, and scaling tests up to 500 entities.
Summary
| Comparison | Average token savings |
|---|---|
| MD-LD vs JSON-LD | 55.4% |
| MD-LD vs TTL | 29.5% |
| TTL vs JSON-LD | 40.3% |
Results confirmed across two tokenizers: cl100k_base (GPT-4) and o200k_base (GPT-4o). Savings differ by less than 1% between tokenizers.
MD-LD carries 2.5x more RDF triples per token than JSON-LD and 1.4x more than TTL.
In a 128K context window with 120K tokens reserved for data: MD-LD fits ~2,884 person records, TTL fits ~2,675, JSON-LD fits ~2,055.
Per-Example Results (cl100k_base)
| Example | Triples | JSON-LD | TTL | MD-LD | vs JSON-LD | vs TTL |
|---|---|---|---|---|---|---|
| Simple Person | 5 | 114 | 66 | 46 | -59.6% | -30.3% |
| Org + Members | 11 | 221 | 133 | 88 | -60.2% | -33.8% |
| Task Management | 20 | 339 | 286 | 224 | -33.9% | -21.7% |
| Academic Research | 10 | 271 | 194 | 118 | -56.5% | -39.2% |
| API Documentation | 10 | 215 | 147 | 102 | -52.6% | -30.6% |
| Complex Nested Graph | 20 | 472 | 266 | 220 | -53.4% | -17.3% |
| Diff / Retraction | 4 | 219 | 93 | 62 | -71.7% | -33.3% |
| Average | -55.4% | -29.5% |
Side-by-Side Example
The same person record in all three formats:
JSON-LD (114 tokens, 335 chars):
json
{
"@context": {
"ex": "tag:alice@example.org,2026:",
"prov": "http://www.w3.org/ns/prov#",
"name": "ex:name",
"fullName": "ex:fullName",
"email": "ex:email"
},
"@id": "tag:alice@example.org,2026:alice",
"@type": "prov:Person",
"name": "Alice",
"fullName": "Alice Smith",
"email": "alice@example.com"
}TTL (66 tokens, 198 chars):
turtle
@prefix ex: <tag:alice@example.org,2026:> .
@prefix prov: <http://www.w3.org/ns/prov#> .
ex:alice a prov:Person ;
ex:name "Alice" ;
ex:fullName "Alice Smith" ;
ex:email "alice@example.com" .MD-LD (46 tokens, 133 chars):
markdown
[ex] <tag:alice@example.org,2026:>
# Alice {=ex:alice .prov:Person label}
[Alice Smith] {ex:fullName}
[alice@example.com] {ex:email}Same 5 RDF triples. MD-LD is 59.6% fewer tokens than JSON-LD and 30.3% fewer than TTL.
Semantic Density
Raw token counts can be misleading — a format that uses fewer tokens but encodes less information is not truly more efficient. Semantic density (triples per token) normalizes for information content:
| Example | JSON-LD | TTL | MD-LD | MD-LD / JSON-LD | MD-LD / TTL |
|---|---|---|---|---|---|
| Simple Person | 0.044 | 0.076 | 0.109 | 2.48x | 1.43x |
| Org + Members | 0.050 | 0.083 | 0.125 | 2.50x | 1.51x |
| Diff / Retraction | 0.018 | 0.043 | 0.065 | 3.61x | 1.51x |
| Average | 0.042 | 0.067 | 0.109 | 2.50x | 1.43x |
Scaling Behavior
Token cost grows linearly with entity count. MD-LD's advantage persists at scale:
| Records (N) | JSON-LD | TTL | MD-LD | vs JSON-LD | vs TTL |
|---|---|---|---|---|---|
| 10 | 677 | 495 | 440 | -35.0% | -11.1% |
| 50 | 2,970 | 2,268 | 2,093 | -29.5% | -7.7% |
| 100 | 5,837 | 4,485 | 4,160 | -28.7% | -7.2% |
| 500 | 28,770 | 22,218 | 20,693 | -28.1% | -6.9% |
Per-record token cost (constant at any scale):
| Format | Per-record tokens |
|---|---|
| JSON-LD | 58.4 |
| TTL | 44.9 |
| MD-LD | 41.6 |
MD-LD saves 16.8 tokens per record vs JSON-LD and 3.3 tokens vs TTL — consistently, at any scale.
Context Window Utilization
In a 128K context window with 8K reserved for instructions (120K available for data):
| Format | Per-record cost | Records in 120K tokens |
|---|---|---|
| JSON-LD | 58.4 | 2,055 |
| TTL | 44.9 | 2,675 |
| MD-LD | 41.6 | 2,884 |
MD-LD fits 829 more records than JSON-LD and 209 more than TTL in the same context window.
Cost Implication
At GPT-4-class pricing (~$3/million input tokens), a full 128K context of knowledge graph data costs:
| Format | Cost per request |
|---|---|
| JSON-LD | $0.36 |
| TTL | $0.28 |
| MD-LD | $0.26 |
MD-LD saves $0.10 per request vs JSON-LD. For 1,000 requests/day, that is approximately $36,500/year.
Why MD-LD Is More Token-Efficient
Four structural advantages explain the savings:
1. No structural scaffolding
JSON-LD spends tokens on {, }, ", :, ,, and key names ("@id", "@type", "@context") that carry zero RDF semantics. TTL reduces this but still requires ;, ., and string delimiters. MD-LD uses Markdown's natural structure as semantic carriers.
2. Prefix folding with positional context
MD-LD declares a prefix once and sets the subject via headings. TTL must re-state the subject for each new node. This eliminates per-node subject re-declaration.
3. Inline compaction
A single MD-LD annotation can encode multiple triples:
markdown
[Alice Chen] {+ex:alice ?org:member .prov:Person label}This one line produces three triples: the ?org:member object property, the .prov:Person type declaration, and the implicit rdfs:label "Alice Chen". In TTL, three separate predicate-object pairs. In JSON-LD, a full nested object.
4. Diff-native semantics
MD-LD's polarity system is built into the syntax. Expressing corrections requires no out-of-band metadata — just -predicate inline. This is why the Diff/Retraction example shows the largest savings (71.7% vs JSON-LD).
Where MD-LD Wins Most vs JSON-LD
| Example | Savings | Why |
|---|---|---|
| Diff / Retraction | -71.7% | JSON-LD has no retraction mechanism; MD-LD's - prefix handles it inline |
| Org + Members | -60.2% | MD-LD collapses member type + label + relationship into one annotation |
| Simple Person | -59.6% | JSON-LD @context is pure overhead, no triples produced |