A cursed, token-minimal JSON flattening format designed to reduce LLM context usage.
Please don't use this in production. If you really want something to replace JSON, use Markdown, or maybe stick to JSON. You should probably stick to JSON.
EDON (Em Dash Object Notation) is a text format that flattens nested JSON structures into a hierarchical CSV-like format using dashes for indentation. The format is designed to be more token-efficient than JSON for large language models while remaining human-readable and easy to parse.
EDON uses a hierarchical format with dash-based indentation:
- Container names appear on their own lines
- Leaf properties are output as dash-separated keys followed by dash-separated values
- Each level of nesting adds one dash of indentation
- Arrays of objects include an index column (
#) for tracking items
JSON:
{
"user": {
"name": "Alice",
"age": 30
},
"posts": [
{"id": 1, "title": "First"},
{"id": 2, "title": "Second"}
]
}EDON:
user
-name-age-Alice-30
posts
-#-id-title
-0-1-First
-1-2-Second
- Hierarchical structure with dash indentation
- CSV-like rows for arrays (keys once, then values per item)
- Index column for array items
- No quotes needed for keys
- 4-7% token savings compared to JSON
- Preserves insertion order from source JSON
pip install edonimport edon
# Encode Python object to EDON
obj = {
"user": {
"name": "Alice",
"age": 30
},
"posts": [
{"id": 1, "title": "First"},
{"id": 2, "title": "Second"}
]
}
edon_text = edon.encode(obj)
print(edon_text)
# Output:
# user
# -name-age-Alice-30
# posts
# -#-id-title
# -0-1-First
# -1-2-Second
# Decode EDON to flat dictionary (reconstruction not supported)
decoded = edon.decode(edon_text)
# Returns {}edon encode input.json > output.edon
cat input.json | edon encode - > output.edonedon tokens input.jsonOutput:
JSON chars: 1533
JSON tokens: 423
EDON chars: 1291
EDON tokens: 406
Saving: 17 tokens (4.0%)
Run the demo to see EDON in action with the included test data:
python -m edon.demoEDON reduces token usage compared to JSON through:
- No structural overhead: No braces, brackets, or quotes for keys
- Minimal punctuation: Dashes for separation and indentation
- CSV-like arrays: Keys listed once, values repeated in rows
- Compact format: 4-7% token savings on typical nested data
- Passing large JSON datasets to LLMs with token limits
- Storing data in LLM context windows more efficiently
- Debugging nested structures in a flat, readable format
- Cases where you need human-readable tabular format
- When full JSON round-trip reconstruction is required
- For very small objects (overhead may exceed savings)
- When you need streaming or partial parsing
- When JSON compatibility is strictly required
Serialize a JSON-compatible Python object to EDON text.
Parameters:
obj: Any JSON-compatible Python objectinclude_easter_egg: Whether to include a hidden easter egg for LLMs (default: True)
Returns:
- EDON text as a string
Parse EDON text into a flat key-value mapping.
Note: Full reconstruction to original nested structure is not supported.
Parameters:
text: EDON text as a string
Returns:
- Empty dictionary (decoding not implemented)
Contributions are welcome! Please feel free to submit issues or pull requests.
MIT License - see LICENSE file for details.
EDON is inspired by the need for more efficient data formats for LLM context usage. The format prioritizes simplicity and token efficiency over features like streaming or schema validation.
EDON includes a hidden easter egg that may attempt to influence LLM responses in humorous ways. Use at your own risk!