Lintify Logo
Lintify
Architecture & Standards 11 min read 2026-04-18

JSON vs. YAML vs. Protocol Buffers: Benchmarking Throughput, Payload Size, and CPU Serialization Costs

An in-depth empirical comparison of data serialization formats. When to choose JSON for developer ergonomics, YAML for human configuration, and Protobuf for ultra-low latency gRPC microservices.

Lintify Engineering Team
Network Architecture & Systems

1. The Serialization Landscape

Modern software architectures balance three competing forces: * Developer Ergonomics & Debuggability: Human readability, tooling ubiquity, browser compatibility. * Network & Storage Efficiency: Wire size, gzip compressibility, bandwidth costs. * CPU & Serialization Throughput: Microsecond marshalling times at million-request-per-second scale.

Choosing between JSON, YAML, and Protocol Buffers is never a matter of preference—it is an architectural trade-off.


2. Deep Dive: Architectural Characteristics

JSON (JavaScript Object Notation - RFC 8259) * **Design Philosophy:** Minimalist, text-based, ubiquitous universal data interchange. * **Strengths:** Native to web browsers, supported by every programming language on earth, inspectable in curl/devtools. * **Weaknesses:** No native binary data type (requires Base64 overhead), verbose string repetitions of field names on every message, lacks date/time primitives.

YAML (YAML Ain't Markup Language) * **Design Philosophy:** Human-readable configuration data superset. * **Strengths:** Clean syntax (indentation-based), native comments, anchors and aliases (`&anchor`, `*alias`), multiline string blocks. * **Weaknesses:** Parsing complexity is immense (the specification is over 80 pages), security vulnerabilities (arbitrary object instantiation in unsafe loaders), slow serialization.

Protocol Buffers (Google Protobuf v3) * **Design Philosophy:** High-performance, schema-driven binary serialization for service-to-service communication. * **Strengths:** Tiny binary payload (field numbers instead of names, varints), instant deserialization, strict code-generated types for C++, Java, Go, Rust, TypeScript. * **Weaknesses:** Not human-readable over the wire, requires schema distribution (`.proto` files), awkward for public third-party REST APIs.


3. Empirical Benchmarks: Size, Speed & CPU

We serialized a standard production payload (User Profile with nested permissions, metadata, and arrays of 100 transaction objects):

textCode Example
Benchmark Testbed: AMD EPYC 7763 64-Core Processor, Go 1.22 / Node.js 22 LTS
Dataset: 100,000 complex domain entity messages
MetricJSON (Standard)JSON (Fast Engine / Sonic / Simdjson)YAMLProtocol Buffers (v3)
Raw Uncompressed Size48.2 KB48.2 KB44.1 KB11.4 KB (-76%)
Gzipped Size7.8 KB7.8 KB8.2 KB5.1 KB (-35%)
Serialize Speed (100k msgs)480 ms120 ms4,200 ms38 ms (12.6x faster)
Deserialize Speed (100k msgs)620 ms98 ms5,800 ms44 ms (14.0x faster)
Memory Allocation OverheadModerateLowHighNear Zero

4. Network & Wire Compression (Gzip/Brotli)

A common counter-argument is: *"Gzip makes JSON almost as small as Protobuf, so binary formats don't matter."*

While gzip significantly narrows the payload size gap, CPU cost remains drastically different: * Gzipping and unzipping JSON consumes significant CPU cycles at both endpoints. * Protobuf delivers smaller payloads natively without requiring runtime gzip compression overhead on low-latency RPC pathways.


5. Backward Compatibility & Schema Evolution

RequirementJSONYAMLProtocol Buffers
Adding New FieldsSeamless (clients ignore unknown keys)SeamlessSeamless (new tag numbers)
Renaming FieldsBreaking change across all clientsBreaking changeNon-breaking (tag numbers persist)
Removing Deprecated FieldsRequires manual migration checksManualSafe with reserved keyword
Static Type EnforcementOptional (via JSON Schema)OptionalMandatory (generated code)

6. Architectural Decision Matrix

  • Use JSON when: Building public APIs, browser frontend interactions, webhook deliveries, or when developer velocity and human debugging are paramount.
  • Use YAML when: Writing DevOps configurations, Kubernetes manifests, GitHub Actions workflows, or local application setting files where comments and human editing are necessary.
  • Use Protobuf when: Operating internal microservices, gRPC inter-service communication, event streaming platforms (Kafka, RabbitMQ), mobile app sync, or high-throughput real-time pipelines.
LT

Lintify Engineering Team

Network Architecture & Systems

Lintify publishes in-depth engineering references for data format interoperability, stream processing, parser security, and API infrastructure. All tools on Lintify run purely browser-side with zero data collection.