<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Webassembly on kmcd.dev</title><link>https://kmcd.dev/tags/webassembly/</link><description>Recent content in Webassembly on kmcd.dev</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>All Rights Reserved</copyright><lastBuildDate>Thu, 25 Jun 2026 10:00:00 +0000</lastBuildDate><atom:link href="https://kmcd.dev/tags/webassembly/index.xml" rel="self" type="application/rss+xml"/><item><title>Exploring Protocol Buffers Interactively</title><link>https://kmcd.dev/posts/interactive-protobuf/</link><pubDate>Thu, 25 Jun 2026 10:00:00 +0000</pubDate><guid>https://kmcd.dev/posts/interactive-protobuf/</guid><description> 
                &lt;p> &lt;img hspace="5" src="https://kmcd.dev/posts/interactive-protobuf/cover.svg" /> &lt;/p>
                
                Announcing protobuf.kmcd.dev, an interactive explainer and playground for exploring the binary details of Protocol Buffers.
                </description><content:encoded><![CDATA[<p>Protocol Buffers (protobuf) are a core part of modern RPCs, schema-driven APIs, and microservices. They work well, but learning how the format operates under the hood can be dry. Most of us stick to the high-level basics (like message fields and primitive types) and rarely need to dig into the wire format, varints, ZigZag encoding, or compiler plugins.</p>
<p>I wanted to change that by building a visual, hands-on guide.</p>
<p>Today I am sharing <strong><a href="https://protobuf.kmcd.dev" rel="external">protobuf.kmcd.dev</a></strong>. It is an interactive playground for exploring Protocol Buffers, from schema design and validation to binary wire formats and serialization efficiency.</p>
<figure><a href="https://kmcd.dev/posts/interactive-protobuf/fixed-size-diagram.png" class="spotlight" data-download="true" aria-label="A diagram showing fixed-size fields being encoded into protobuf">
    
    
    
    
        
            
            
                
            
            
        
    

    
    
    

    
    
        
    

    <img src="https://kmcd.dev/posts/interactive-protobuf/fixed-size-diagram_hu_8380e5299910fee0.png"
         alt="A diagram showing fixed-size fields being encoded into protobuf" loading="lazy"/>
    </a>
</figure>

<p>This builds on a previous experiment, <strong><a href="https://bgp.kmcd.dev" rel="external">bgp.kmcd.dev</a></strong>, which I introduced in <a href="https://kmcd.dev/posts/bgp-kmcd-dev/">Let&rsquo;s Learn About BGP</a>. That project showed me how much easier it is to understand the inner workings of a protocol when you can see them update in real time. I wanted to apply that same approach here.</p>
<hr>
<h2 id="a-quick-tour">A Quick Tour</h2>
<p>Instead of just writing static text, I built several custom widgets and sandboxes to show what happens when you compile and serialize protobuf data.</p>
<h3 id="deep-dive-into-the-basics">Deep Dive into the Basics</h3>
<p>The <a href="https://protobuf.kmcd.dev/basics/" rel="external">Basics</a> section covers schema design syntax and core protobuf concepts like enums, nested messages, repeated fields, maps, and oneofs. Code comparisons help explain primitive scalars, Google&rsquo;s Well-Known Types, and optimal integer guidelines.</p>
<h3 id="visualizing-the-wire-format">Visualizing the Wire Format</h3>
<p>The <a href="https://protobuf.kmcd.dev/binary/" rel="external">Binary &amp; Wire Format</a> page contains the core interactive tools on the site, and it is the section I am most interested in getting your thoughts on. It explains some basics of working with binary and then it breaks down how bytes are physically laid out on the wire:</p>
<ul>
<li><strong>Varint Explainer:</strong> An interactive bit-level calculator. Input any integer to see how it converts from decimal to binary, splits into 7-bit groups, attaches continuation flags (MSB), and outputs final hex bytes.</li>
<li><strong>ZigZag Explainer:</strong> Input signed numbers and watch how the sign bit shifts to the LSB, showing the resulting bit arrangement and ZigZag value.</li>
<li><strong>Tag Calculator:</strong> Select a field number and a wire type to see the mathematical shift (<code>&lt;&lt; 3</code>), bitwise OR operations, and the resulting hex tag byte.</li>
<li><strong>Interactive Wire Type Visualizers:</strong> Flowcharts that explain wire-type parsing for Varints, Fixed width (32-bit and 64-bit), and Length-delimited payloads.</li>
<li><strong>Binary Explorer (Segment Inspector):</strong> An interactive split layout. You write a custom protobuf schema and standard JSON data. The tool compiles the schema, encodes the JSON to raw binary bytes, and maps them to a hex grid. Hovering or clicking on individual bytes in the grid highlights them and opens an inspector pane that breaks down exactly which field number, wire type, length, or payload value those bytes represent. You can also toggle a live Protoscope view to see the binary translate into diagnostic text.</li>
</ul>
<figure><a href="https://kmcd.dev/posts/interactive-protobuf/binary-explorer.png" class="spotlight" data-download="true" aria-label="The Binary Explorer split layout showing a schema compiling to a raw hex grid">
    
    
    
    
        
            
            
                
            
            
        
    

    
    
    

    
    
        
    

    <img src="https://kmcd.dev/posts/interactive-protobuf/binary-explorer_hu_3cc7be83abbe0dee.png"
         alt="The Binary Explorer split layout showing a schema compiling to a raw hex grid" loading="lazy"/>
    </a>
</figure>

<ul>
<li><strong>Protoscope Lab:</strong> A diagnostic sandbox where you can write raw Protoscope text on the left and see it compile into hex bytes on the right.</li>
</ul>
<p><em>I am particularly interested in whether this section hits the mark. Are these visualizations actually helpful for understanding the low-level encoding, or do they feel too contrived?</em></p>
<figure><a href="https://kmcd.dev/posts/interactive-protobuf/varint-calculator.png" class="spotlight" data-download="true" aria-label="The Varint Explainer widget showing a live bit-level decimal to binary conversion">
    
    
    
    
        
            
            
                
            
            
        
    

    
    
    

    
    
        
    

    <img src="https://kmcd.dev/posts/interactive-protobuf/varint-calculator_hu_e24c34b464040124.png"
         alt="The Varint Explainer widget showing a live bit-level decimal to binary conversion" loading="lazy"/>
    </a>
</figure>

<h3 id="real-time-benchmarking--efficiency">Real-Time Benchmarking &amp; Efficiency</h3>
<p>The <a href="https://protobuf.kmcd.dev/efficiency/" rel="external">Efficiency &amp; Performance</a> page features a simulator with a JSON editor on the left and live metrics on the right.</p>
<p>You can write your own JSON structure or load preset profiles (Basic User, Nested Data, Packed List). The app compiles the schema, encodes the JSON into protobuf binary, and runs both payloads through browser-native GZIP compression. It renders bar charts comparing minified/gzipped JSON versus protobuf binary sizes, showing the payload reduction ratio. It also includes alerts for things like Gzip overhead if your payload is too small to benefit from compression.</p>
<figure><a href="https://kmcd.dev/posts/interactive-protobuf/efficiency.png" class="spotlight" data-download="true" aria-label="Real-time dashboard rendering animated bar charts that compare JSON and Protobuf payload sizes">
    
    
    
    
        
            
            
                
            
            
        
    

    
    
    

    
    
        
    

    <img src="https://kmcd.dev/posts/interactive-protobuf/efficiency_hu_940270c68dfa7d7c.png"
         alt="Real-time dashboard rendering animated bar charts that compare JSON and Protobuf payload sizes" loading="lazy"/>
    </a>
</figure>

<h3 id="options-reflection-and-validation">Options, Reflection, and Validation</h3>
<p>The <strong><a href="https://protobuf.kmcd.dev/tooling/" rel="external">Tooling &amp; Reflection</a></strong> and <strong><a href="https://protobuf.kmcd.dev/advanced/" rel="external">Advanced</a></strong> pages contain two developer sandboxes:</p>
<ul>
<li><strong>Descriptor Playground:</strong> Write protobuf schemas and inspect the compiled <code>FileDescriptorSet</code> JSON metadata structure in real time. You can download the output directly as a raw binary descriptor (<code>descriptor.bin</code>) or a JSON file.</li>
<li><strong>Validation Lab:</strong> An interactive sandbox illustrating the <code>protovalidate</code> specification. You can write schemas containing CEL (Common Expression Language) validation rules (like <code>this.age &gt;= 18</code>) and test them against JSON payloads. If violations occur, the page displays a list of validation errors, naming the violating fields and the failed constraint rules.</li>
</ul>
<h3 id="the-protobuf-ecosystem">The Protobuf Ecosystem</h3>
<p>This page contains a searchable index of protobuf-related projects, including compilers, linters, formatters, validators, RPC frameworks, and language-specific tooling. Whether you&rsquo;re looking for a code generator, validation framework, or language-specific library, the explorer makes it easier to discover tools across the broader protobuf ecosystem.</p>
<p>Explore the complete list at <strong><a href="https://protobuf.kmcd.dev/ecosystem/" rel="external">protobuf.kmcd.dev/ecosystem</a></strong>.</p>
<hr>
<h2 id="powered-by-webassembly-wasm">Powered by WebAssembly (WASM)</h2>
<p>Building interactive compilers in a web browser usually requires a round-trip to a backend server or rewriting everything in TypeScript. To avoid the server costs of passing custom schemas to a backend or the development time of porting several different libraries to TypeScript, this site runs Go&rsquo;s compiler tooling directly inside the browser using WebAssembly.</p>
<p>As I noted in <a href="https://kmcd.dev/posts/wasm-demos/">Zero-Friction Demos with WASM</a>, compiling Go libraries into WASM works really well for client-side tools. The WASM binary handles the schema compilation, JSON-to-binary serialization, and Protoscope compilation natively on the client. It is fast, private, and works offline.</p>
<h2 id="give-it-a-spin">Give it a Spin</h2>
<p>If you want to look at the lower-level mechanics of Protocol Buffers, or if you just need a zero-install scratchpad to inspect wire formats and CEL validations, check out the site starting from the <strong><a href="https://protobuf.kmcd.dev/intro/" rel="external">Introduction</a></strong>:</p>
<p>👉 <strong><a href="https://protobuf.kmcd.dev" rel="external">protobuf.kmcd.dev</a></strong></p>
<p>The source code and widgets are open source and available on GitHub at <strong><a href="https://github.com/sudorandom/protobuf.kmcd.dev" rel="external">sudorandom/protobuf.kmcd.dev</a></strong>. Please give the site a try and let me know your thoughts (especially on the binary section), bug reports, or suggestions!</p>
]]></content:encoded></item></channel></rss>