# bytepeel

> Peel layers of encoding off binary data, byte-exactly. A CLI, an MCP server and a library, built for AI agents.

bytepeel decodes encoded and binary data layer by layer: hex, base64, PEM,
JWTs, `xxd`/`hexdump -C` dumps, gzip/zlib/zstd, DER/ASN.1, CBOR, MessagePack
and schemaless protobuf, nested in any order. It is built so that AI coding
agents can call it instead of reading bytes by eye or writing a throwaway
decoding script.

```console
$ printf 'ChRTR1ZzYkc4c0lIZHZjbXhrSVNFPRAq' | bytepeel --format tree
base64(std,padded) [0..32] conf=0.85 -> 24 bytes
  protobuf [0..24] conf=0.90
    #1 LEN [0..22] len=20: string 0.95 "SGVsbG8sIHdvcmxkISE=" | packed_varint 0.03 | bytes 0.02
      base64(std,padded) [0..20] conf=0.95 -> 14 bytes
        utf8 [0..14] conf=1.00 "Hello, world!!"
    #2 VARINT [22..24] uint=42 int=42 sint=21
```

- **Recursive:** base64 → protobuf → a string field that is base64 again →
  text, in one call.
- **Honest about ambiguity:** each protobuf LEN field lists ranked
  interpretations (`message`, `string`, `packed_varint`, `bytes`), and each
  varint shows its `uint`, `int` and `sint` views.
- **Agent-friendly:** compact JSON by default, byte ranges on everything,
  64-bit integers as strings (safe for jq and JavaScript), and errors as
  `{"error":{"code","message","offset"}}` with stable codes.
- **Edits too:** `bytepeel set` changes a value deep inside and re-encodes
  every layer in its original style.
- **Small:** a zero-dependency Rust core and a single static binary.

```sh
npx bytepeel --help              # the CLI and MCP server, no install needed
npm install -g bytepeel          # or install it (Node 18+)
cargo install bytepeel           # or build it (Rust 1.87+)
```

## Where to go next

- [Install](https://bytepeel.pinta.land/guide/install/index.md) for every way to get it, including
  prebuilt binaries.
- [Decoding](https://bytepeel.pinta.land/guide/decoding/index.md) and [Editing](https://bytepeel.pinta.land/guide/editing/index.md)
  for the command line.
- [MCP server](https://bytepeel.pinta.land/guide/mcp/index.md) and [Agents](https://bytepeel.pinta.land/guide/agents/index.md) to
  give an AI agent the tool.
- [JavaScript](https://bytepeel.pinta.land/guide/javascript/index.md) and [Rust](https://bytepeel.pinta.land/guide/rust/index.md) for
  the libraries.
- The [Reference](https://bytepeel.pinta.land/reference/index.md) for the JSON schema, paths and
  error codes.
