# @royaltm/inspect-protobuf

> inspect or convert protobuf encoded messages to json, best served with kafkacat

Latest version **1.3.0** (published 2021-01-04) · LGPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install @royaltm/inspect-protobuf
pnpm add @royaltm/inspect-protobuf
yarn add @royaltm/inspect-protobuf
bun add @royaltm/inspect-protobuf
```

Provides the command `inspect-protobuf`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2021-01-04 |
| First published | 2017-04-28 |
| Weekly downloads | 0 |
| License | LGPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 5 |
| Unpacked size | 32.3 KB |
| Known vulnerabilities | 0 (+11 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | royal@yeondir.com |
| Maintainers | royaltm |
| Keywords | protobuf, inspect, kafkacat |

## Links

- npm: https://www.npmjs.com/package/@royaltm/inspect-protobuf
- Repository: https://github.com/royaltm/inspect-protobuf
- Homepage: https://github.com/royaltm/inspect-protobuf#readme
- Issues: https://github.com/royaltm/inspect-protobuf/issues
- npm.io page: https://npm.io/package/@royaltm/inspect-protobuf

## Dependencies (5)

- [long](https://npm.io/package/long.md) ^4.0.0
- [commander](https://npm.io/package/commander.md) ^6.2.1
- [protobufjs](https://npm.io/package/protobufjs.md) ^6.10.2
- [msgpack-lite](https://npm.io/package/msgpack-lite.md) ^0.1.26
- [protocol-buffers](https://npm.io/package/protocol-buffers.md) ^4.2.0

## Recent versions

- 1.3.0 (latest) — 2021-01-04
- 1.2.0 — 2018-01-18
- 1.1.0 — 2017-05-30
- 1.0.0 — 2017-04-28

## README

inspect-protobuf
================

Inspect the content of messages encoded with google protobuf.


### Requirements

* nodejs ^8


### Installation


```
sudo npm install -g @royaltm/inspect-protobuf
```

### Usage

#### Display help

```
inspect-protobuf -h
```

```
Usage: inspect-protobuf [options] <proto-file> <ProtoMessageName>


Options:

  -V, --version           output the version number
  -j, --json              json output
  -C, --no-color          monochrome inspect output
  -3, --proto-3           use protobufjs parser (proto-3 support)
  -I, --no-ip             do not decode 4 or 16 bytes as ip addresses
  -e, --bytes <encoding>  decode bytes as strings with encoding
  -m, --msgpack           decode bytes with MessagePack
  -b, --json-bytes        decode bytes as JSON strings
  -h, --help              output usage information
```

#### Arguments

Pass proto file and message name arguments.
If message name is not provided the first message found in proto file will be used.

```
cat message.bin | inspect-protobuf path/to/file.proto MyMessage
```

Alternatively set the environment variable `INSPECT_PROTOBUF="path/to/file.proto/MyMessage"`.
In this instance you *must* append the message name as the last path component.

##### Format options

no colors

```
cat message.bin | inspect-protobuf -C
```

use external json inspector

```
cat message.bin | inspect-protobuf -j | jq .
```

##### Protobuf options

Switch to [protobufjs](https://www.npmjs.com/package/protobufjs) module for proto3 and other protobuf features that are not handled by the [protocol-buffers](https://www.npmjs.com/package/protocol-buffers) module.

```
cat message.bin | inspect-protobuf -3
```

#### Kafkacat

This tool is best served with [kafkacat](https://github.com/edenhill/kafkacat).

```
export INSPECT_PROTOBUF="path/to/file.proto/MessageName"
kafkacat -C -b BROKER.BOOTSTRAP.NAME -c 20 -t SOME_TOPIC_NAME -o -1 -f '%S %s' | inspect-protobuf
```

The important part is `kafkacat ... -f '%S %s'`. It prepends each message with its byte length, so `inspect-protobuf` can distinguish each message in a message stream.

---
_Source: https://npm.io/package/@royaltm/inspect-protobuf · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
