Binary data,
made legible.
CStructSharp reads and writes binary data using a description that looks like a C struct. Give it a layout and some bytes, and it gives you named values. Give it values, and it creates bytes or changes a field in existing data — from C#, Node.js, or JavaScript in a browser, using the exact same layout language.
Zero runtime package dependencies. The core .NET library uses only the .NET runtime, keeping integration simple and your application's dependency tree small.
Binary inspector
Parse a real file — BMP, WAV, ZIP, PNG, an EXE, and more — against an editable schema, with clickable fields cross-highlighted in the hex view.
Interactive lessons
Run the managed parser in WebAssembly right here in the page. Work through guided lessons or experiment freely with parse, serialize, and update operations.
Documentation
Guides, the complete layout-language reference, API documentation, examples, and project maintenance notes.
Parse the same six bytes twice
The same layout string works on both sides — describe it once, and read it from a .NET process or a Node.js process or browser tab.
using CStructSharp;
var layout = new CStruct("struct header { uint16 kind; uint32 length; };");
byte[] bytes = { 0x02, 0x00, 0x06, 0x00, 0x00, 0x00 };
dynamic header = layout.Parse(bytes.AsSpan(), "header");
Console.WriteLine($"kind = {header.kind}");
Console.WriteLine($"length = {header.length}");
import { parse } from "cstructsharp";
const definition = "struct header { uint16 kind; uint32 length; };";
const bytes = new Uint8Array([0x02, 0x00, 0x06, 0x00, 0x00, 0x00]);
const result = await parse(definition, bytes, { root: "header" });
if (!result.success) throw new Error(result.error.message);
const header = result.data;
console.log(`kind = ${header.kind}`);
console.log(`length = ${header.length}`);
Install
.NET / C#
Requires a stable .NET 10 SDK. Targets .NET 8 and .NET 10.
dotnet add package CStructSharp
Add it to an existing project, or start a new one with dotnet new console first.
JavaScript / WebAssembly
Node.js 22.14+ and browsers. Includes the WASM runtime; no .NET installation required.
npm install cstructsharp
Save the example above as example.mjs and run node example.mjs, or follow the
JavaScript quick start to configure the included Vite
plugin for a browser app. The guide also covers the optional standalone browser ZIP.