# protocol-buffers-schema

> No nonsense protocol buffers schema parser written in Javascript

Latest version **3.6.1** (published 2026-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install protocol-buffers-schema
pnpm add protocol-buffers-schema
yarn add protocol-buffers-schema
bun add protocol-buffers-schema
```

## Health

**Score 53/100 (C)** — status: active.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.6.1 |
| Published | 2026-04-06 |
| First published | 2015-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/protocol-buffers-schema) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 67.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 122 |
| Author | Mathias Buus |
| Maintainers | mafintosh |
| Keywords | protobuf, protocol, buffers, schema, parser, parse |

## Links

- npm: https://www.npmjs.com/package/protocol-buffers-schema
- Repository: https://github.com/mafintosh/protocol-buffers-schema
- Issues: https://github.com/mafintosh/protocol-buffers-schema/issues
- npm.io page: https://npm.io/package/protocol-buffers-schema

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 3.6.1 (latest) — 2026-04-06
- 3.6.0 — 2021-09-09
- 3.5.2 — 2021-08-11
- 3.5.1 — 2021-01-19
- 3.5.0 — 2021-01-19
- 3.4.0 — 2020-01-24
- 3.3.3 — 2020-01-14
- 3.3.2 — 2017-09-22
- 3.3.1 — 2017-05-08
- 3.3.0 — 2017-04-11
- 3.2.0 — 2017-04-10
- 3.1.1 — 2016-11-25
- 3.1.0 — 2016-04-09
- 3.0.0 — 2015-12-14
- 2.2.0 — 2015-12-05
- … 7 more at https://npm.io/package/protocol-buffers-schema/versions

## README

# protocol-buffers-schema

No nonsense [protocol buffers](https://developers.google.com/protocol-buffers) schema parser written in Javascript

``` js
npm install protocol-buffers-schema
```

[![build status](http://img.shields.io/travis/mafintosh/protocol-buffers-schema.svg?style=flat)](http://travis-ci.org/mafintosh/protocol-buffers-schema)

## Usage

First save the following file as `example.proto`

```proto
syntax = "proto2";

message Point {
  required int32 x = 1;
  required int32 y=2;
  optional string label = 3;
}

message Line {
  required Point start = 1;
  required Point end = 2;
  optional string label = 3;
}
```

The run the following example

``` js
var fs = require('fs')
var schema = require('protocol-buffers-schema')

// pass a buffer or string to schema.parse
var sch = schema.parse(fs.readFileSync('example.proto'))

// will print out the schema as a javascript object
console.log(sch)
```

Running the above example will print something like

``` js
{
  syntax: 2,
  package: null,
  enums: [],
  messages: [{
    name: 'Point',
    enums: [],
    messages: [],
    options: {},
    fields: [{
      name: 'x',
      type: 'int32',
      tag: 1,
      required: true,
      repeated: false,
      options: {}
    }, {
      name: 'y',
      type: 'int32',
      tag: 2,
      required: true,
      repeated: false,
      options: {}
    }, {
      name: 'label',
      type: 'string',
      tag: 3,
      required: false,
      repeated: false,
      options: {}
    }]
  }, {
    name: 'Line',
    enums: [],
    messages: [],
    options: {},
    fields: [{
      name: 'start',
      type: 'Point',
      tag: 1,
      required: true,
      repeated: false,
      options: {}
    }, {
      name: 'end',
      type: 'Point',
      tag: 2,
      required: true,
      repeated: false,
      options: {}
    }, {
      name: 'label',
      type: 'string',
      tag: 3,
      required: false,
      repeated: false,
      options: {}
    }]
  }],
  options:{}
}
```

## API

#### `schema.parse(protobufSchemaBufferOrString)`

Parses a .proto schema into a javascript object

#### `schema.stringify(schema)`

Stringifies a parsed schema back into .proto format

## License

MIT

---
_Source: https://npm.io/package/protocol-buffers-schema · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
