Introduction
ASON (Aliased Serialization Object Notation) is a serialization format designed to optimize token consumption in LLM (Large Language Model) contexts while maintaining human readability and guaranteeing complete round-trip fidelity.
Unlike traditional JSON, ASON uses intelligent compression techniques such as object references, value dictionaries, and path flattening to significantly reduce payload size without losing information.
Features
- • Intelligent Compression: Reduces up to 60% of tokens compared to JSON
- • Human Readable: Maintains a clear and easy-to-read structure
- • Perfect Round-Trip: Guaranteed decompression without data loss
- • Reference System: Detects and reuses repeated objects
Installation & Usage
NPM Package
npm install @ason-format/ason
import { SmartCompressor } from '@ason-format/ason';
const compressor = new SmartCompressor();
const data = { users: [{ id: 1, name: "Alice" }] };
const compressed = compressor.compress(data);
const original = compressor.decompress(compressed);
CDN (Browser)
Use ASON directly in the browser without installation:
Option 1: ESM Module
<script type="module">
import { SmartCompressor } from 'https://unpkg.com/@ason-format/ason@1.1.2';
const compressor = new SmartCompressor();
const compressed = compressor.compress({ hello: "world" });
</script>
Option 2: Global Variable
<script src="https://unpkg.com/@ason-format/ason@1.1.2/dist/index.browser.js"></script>
<script>
const { SmartCompressor, TokenCounter } = window.ASON;
const compressor = new SmartCompressor();
</script>
CLI Tool
# Convert JSON to ASON npx ason input.json -o output.ason # Show token savings npx ason data.json --stats # ✓ Saved 36 tokens (61.02%)
Basic Example
Original JSON
195 tokens
{
"users": [
{
"id": 1,
"name": "Alice",
"email": "alice@example.com",
"age": 25,
"active": true
},
{
"id": 2,
"name": "Bob",
"email": "bob@example.com",
"age": 30,
"active": true
},
{
"id": 3,
"name": "Charlie",
"email": "charlie@example.com",
"age": 35,
"active": false
}
]
}
Compressed ASON
35 tokens · -64.6%users:[3]@id,name,email,age,active 1,Alice,alice@example.com,25,true 2,Bob,bob@example.com,30,true 3,Charlie,charlie@example.com,35,false
Compression Techniques
Uniform Arrays
When an array contains objects with the same keys, ASON extracts the keys as a header and stores only the values.
users:[3]@id,name,email 1,Alice,alice@example.com 2,Bob,bob@example.com 3,Charlie,charlie@example.com
Path Flattening
Nested objects with a single property are flattened using dot notation.
// Instead of: config: database: host:localhost // ASON uses: config.database.host:localhost
Value Dictionary (Inline-First)
Frequently repeated strings use an "inline-first" approach optimized for LLMs: the first occurrence shows the complete value with a tag, subsequent occurrences use only the tag.
Advantage for LLMs: The model reads the complete value immediately on first mention, without needing to mentally resolve references. Subsequent occurrences serve as "reminders" of the already-known value.
// First occurrence: shows value + tag billing.email:customer@example.com #0 billing.city:San Francisco #1 // Subsequent occurrences: tag only shipping.email:#0 shipping.city:#1 contact.email:#0
This format reduces cognitive load compared to
formats that require looking up definitions in a
separate $def: section.
Object References
Identical objects that appear multiple times are defined once and referenced afterwards.
&obj0: status:unavailable $data: incremental_authorization:&obj0 multicapture:&obj0
Real-World Use Cases
Stripe Payment Intent
-6.0%Complex JSON with 70+ fields, nested objects, and multiple references.
Array of 50 Products
-59.1%Large list with uniform structure, ideal for compression.
10 Users
-48.2%Typical REST API case with uniform objects.
Comparison with Other Formats
| Feature | JSON | ASON | TOON |
|---|---|---|---|
| Human Readability | Yes | Yes | Yes |
| Average Compression | 0% | 22.1% | 12.3% |
| Object References | No | Yes | No |
| Value Dictionary | No | Yes (inline-first) | No |
| Uniform Arrays | No | Yes | Yes |
| Guaranteed Round-Trip | Yes | Yes | Yes |
When to Use ASON
Ideal Cases
- • Payloads for LLMs with token limits
- • Large arrays with uniform objects
- • APIs with repetitive data
- • Compact structured logging
Not Recommended
- • Very small JSON (<100 chars)
- • Completely heterogeneous data
- • No token limits
- • Compatibility with legacy systems