Meri Leeworthy

Technical comparison of schema definition languages

JSON Schema

Specification: RFC-based standard (Draft 2020-12 is current) Data Model: Tree-structured JSON documents Type System:

Key Features:

Serialization: JSON only Validation: Runtime validation with detailed error reporting Tooling: Extensive cross-language library support

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "age": { "type": "integer", "minimum": 0 }
  },
  "required": ["name"]
}

IPLD Schemas

Specification: IPLD specification with ADL (Advanced Data Layouts) support Data Model: IPLD Data Model with content-addressed linking Type System:

Key Features:

Serialization: Multiple codecs (CBOR, DAG-CBOR, DAG-JSON, etc.) Validation: Compile-time type checking and runtime validation Tooling: Go, JavaScript implementations with code generation

type Person struct {
  name String
  age optional Int
  friends [&Person]  # Links to other Person nodes
} representation map

AT Protocol Lexicons

Specification: AT Protocol specification Data Model: Record-based with NSID (Namespaced Identifier) routing Type System:

Key Features:

Serialization: CBOR for records, JSON for API calls Validation: Schema validation plus protocol-level constraints Tooling: TypeScript/JavaScript with automatic client generation

{
  "lexicon": 1,
  "id": "com.example.profile",
  "defs": {
    "main": {
      "type": "record",
      "key": "literal:self",
      "record": {
        "type": "object",
        "required": ["displayName"],
        "properties": {
          "displayName": {"type": "string", "maxLength": 64},
          "avatar": {"type": "blob", "accept": ["image/*"]}
        }
      }
    }
  }
}

Protocol Buffers

Specification: Google’s protobuf specification Data Model: Message-based with field numbering Type System:

Key Features:

Serialization: Binary protobuf format Validation: Compile-time type checking Tooling: Extensive multi-language support with code generation

syntax = "proto3";

message Person {
  string name = 1;
  int32 age = 2;
  repeated string email = 3;
}

Apache Avro

Specification: Apache Avro specification Data Model: Schema evolution with reader/writer schemas Type System:

Key Features:

Serialization: Binary Avro format, JSON encoding available Validation: Schema matching and evolution validation Tooling: Java, C, C++, C#, Python, Ruby, PHP implementations

{
  "type": "record",
  "name": "Person",
  "fields": [
    {"name": "name", "type": "string"},
    {"name": "age", "type": ["null", "int"], "default": null}
  ]
}

Comparison Matrix

FeatureJSON SchemaIPLD SchemaAT LexiconProtobufAvro
Primary Use CaseJSON validationDecentralized dataSocial protocolRPC/ServicesData serialization
SerializationJSON onlyMulti-codecCBOR/JSONBinaryBinary/JSON
Schema EvolutionLimitedImmutableVersionedField numbersFull support
Type SafetyRuntimeCompile+RuntimeRuntimeCompile-timeRuntime
LinkingURI referencesContent addressingNSID routingImport systemSchema registry
Code GenerationLimitedYesYesExtensiveYes
EcosystemWeb APIsIPFS/Web3Bluesky/ATgRPC/EnterpriseBig Data
Validation ComplexityVery highMediumMediumLowLow
PerformanceSlowFastMediumVery fastFast

Technical Trade-offs

JSON Schema excels at complex validation logic and documentation but has poor performance and limited type safety.

IPLD Schemas provide cryptographic integrity and cross-format compatibility but are complex to implement and have limited tooling.

AT Protocol Lexicons integrate authentication and social networking primitives but are domain-specific and have a smaller ecosystem.

Protocol Buffers offer excellent performance and tooling but require code generation and have limited runtime flexibility.

Apache Avro provides superior schema evolution but is primarily designed for batch processing scenarios and has complex compatibility rules.

I live and work on the land of the Wurundjeri people of the Kulin Nation. I pay respect to their elders past and present and acknowledge that sovereignty was never ceded. Always was, always will be Aboriginal land.

This site uses open source typefaces, including Sligoil by Ariel Martín Pérez, and Vercetti by Filippos Fragkogiannis