Core Concept

Encoding Modes

AXON automatically selects the optimal encoding mode based on your data structure

What You'll Learn

  • All 6 encoding modes: Compact, Nested, Columnar, Stream, Sparse, JSON Fallback
  • How XML input is converted with tag elimination and attribute extraction
  • How to check which mode AXON recommends for your data
COMPACT

Compact Mode

Default for uniform arrays

CSV-like columnar format with type annotations. Best for arrays of similar objects.

NESTED

Nested Mode

For complex hierarchies

Handles objects with arbitrary nesting depth while maintaining compression benefits.

COLUMNAR

Columnar Mode

For large datasets (1000+ rows)

Column-oriented storage optimized for analytics and large tables.

STREAM

Stream Mode

For time-series data

Optimized for sequential data with temporal ordering. Applies delta encoding automatically.

SPARSE

Sparse Mode

For data with >50% nulls

Only stores non-null values with position indices, dramatically reducing size.

JSON

JSON Fallback

For irregular data

Falls back to JSON for highly irregular data where compression wouldn't help.

XML Input Support

AXON can convert XML data directly, which is especially effective due to XML's inherently verbose structure. The conversion process:

  • Tag elimination: Repetitive opening/closing tags become schema definitions
  • Attribute extraction: XML attributes are converted to columnar fields
  • Uniform children: Repeated child elements (like <item>) use columnar format
  • Namespace handling: Common namespaces are compressed via dictionary encoding
// XML input
<products>
  <product id="P001" category="electronics">
    <name>Headphones</name>
    <price>149.99</price>
  </product>
  <product id="P002" category="electronics">
    <name>Speaker</name>
    <price>79.99</price>
  </product>
</products>

// AXON output (conceptual)
@xml
products:
  @schema(product): [@id, @category, name, price]
    @id: ["P001", "P002"]
    @category: "electronics"*2
    name: ["Headphones", "Speaker"]
    price: [149.99, 79.99]

Best for XML: Enterprise data feeds (invoices, orders), configuration files, SOAP responses, and any XML with repeated element structures.

Mode Selection Example

You can check which mode AXON would recommend for your data:

import { getModeRecommendation } from '@axon-format/core';

const data = { /* your data */ };
const recommendation = getModeRecommendation(data);

console.log(recommendation.mode);   // 'columnar'
console.log(recommendation.reason); // Explanatory text

Best Practice: Let AXON choose the mode automatically. Manual override is rarely needed and may reduce compression effectiveness.