Registry / devops / protobuf-schema

protobuf-schema

JSON →
library1.5.1jsnpmunverified

Protobuf-schema v1.5.1 is a simple JavaScript parser for Protocol Buffers schema files (.proto). It converts .proto definitions into plain JavaScript objects and can also stringify objects back to .proto format. Unlike full protobuf libraries (e.g., protobuf.js), this package focuses solely on schema parsing without serialization or code generation. Development appears sparse (last release in 2016) and the package is likely in maintenance mode. Key differentiator: minimal, pure JS parser with no runtime dependencies.

npm install protobuf-schema
INSTALL
IMPORT
SIG · PROTOBUF-SCHEMA
P
protobuf-schema
devopsjavascriptv1.5.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
✓ import { parse } from 'protobuf-schema'
✗ const schema = require('protobuf-schema'); schema.parse(...)
Package does not export a default; named export `parse`.
stringify
✓ import { stringify } from 'protobuf-schema'
✗ var stringify = require('protobuf-schema').stringify
ESM import preferred; CJS still works.
schema
✓ import * as protoSchema from 'protobuf-schema'
✗ const protoSchema = require('protobuf-schema')
Namespace import works in ESM; CJS require still supported.

Parses a hardcoded .proto schema string into a JavaScript object using the named `parse` export.

import { parse } from 'protobuf-schema'; import { readFileSync } from 'fs'; const schemaString = ` message Point { required int32 x = 1; required int32 y = 2; optional string label = 3; } `; const schema = parse(schemaString); console.log(JSON.stringify(schema, null, 2)); // Output: { package: null, enums: [], messages: [...] }
Debug
Known issues
gotchaThe `parse` function accepts strings or Buffers, not direct file paths; use fs.readFileSync.
fix
Use fs.readFileSync('file.proto') to read the file into a string or Buffer.
affects: *
deprecatedNo activity since 2016; may not support newer protobuf syntax (proto3 features like maps, oneof, etc.).
fix
Consider using protobuf.js or @bufbuild/protobuf for modern protobuf support.
affects: *
gotchaNamed exports are used; default import does not work.
fix
Use `import { parse, stringify } from 'protobuf-schema'`.
affects: *
gotchaPackage uses `var` and no semicolons; not TypeScript-friendly, no types bundled.
fix
Install @types/protobuf-schema if available, or create own type stubs.
affects: *
Errors
Common errors & fixes
TypeError: schema.parse is not a function
Importing default export instead of named export.
fix
Use `import { parse } from 'protobuf-schema'` or `const { parse } = require('protobuf-schema')`.
Syntax error: unrecognized syntax identifier
Input uses proto3 syntax keyword 'syntax = "proto3";' which is not supported.
fix
Remove the syntax line or use proto2 style without quotes.
ReferenceError: fs is not defined
Trying to use fs in browser or without importing the module.
fix
In Node, use `import fs from 'fs'`. In browser, pass the schema string directly.
Upgrade
Version history
1.5.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
12
Resources
protobuf-schema — npm install protobuf-schema · libregistry