.pb

What is a .pb file?

Protocol Buffers Binary Data · Data · Google · 2008 (open-sourced)

A .pb file contains data encoded with Protocol Buffers, Google's compact binary serialization. Unlike JSON, the bytes are meaningless without the matching .proto schema that defines the message fields.

Category
Data
Type
Binary
Is a .pb file safe to open? Safe as data; a .pb file does not execute. As with any parser input, decode untrusted files with a current protobuf library.

What is a .pb file used for?

Protobuf messages are streams of numbered, typed fields with no header and no field names, which is what makes them tiny and fast, and also unreadable on their own: you need the .proto definition to decode field numbers back into names.

That schema-first design powers gRPC APIs and many ML artifacts; TensorFlow graphs and ONNX models are protobuf underneath. A .pb file with no known schema can still be partially inspected with protoc --decode_raw.

What opens a .pb file?

The .pb format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list.

Windows

  • protoc (with the .proto schema)
  • Python (protobuf library)

macOS

  • protoc
  • Python (protobuf library)

Linux

  • protoc
  • Python (protobuf library)

Open a .pb file step by step

  1. Confirm the file really is a .pb. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
  2. On Windows, open it with protoc (with the .proto schema) or Python (protobuf library).
  3. On Mac, use protoc or Python (protobuf library).
  4. On Linux, try protoc or Python (protobuf library).
  5. Still stuck? Convert the .pb to json (via schema), which opens more widely.

Why can't I open my .pb file?

Almost always because no installed app understands Protobuf. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.

The other possibility is that the file is not really a .pb at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.

How to convert a .pb file

You can convert a .pb file to json (via schema), txt (decode_raw) using a conversion tool or the export menu of an app that opens it.

Protobuf has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.

Frequently asked questions

What is a .pb file?

A .pb file contains data encoded with Protocol Buffers, Google's compact binary serialization. Unlike JSON, the bytes are meaningless without the matching .proto schema that defines the message fields.

How do I open a .pb file?

With its schema: protoc --decode=package.Message schema.proto < file.pb prints it as text. Without a schema, protoc --decode_raw shows field numbers and raw values.

Why does my .pb file look like random bytes?

By design. Protobuf stores only field numbers and packed values, no names or structure markers, so the .proto definition is required to interpret it.

Is a TensorFlow .pb file the same thing?

Yes at the encoding level: a frozen TensorFlow graph is a protobuf message (GraphDef) saved to a .pb file. TensorFlow tooling, not protoc, is the practical way to load those.

Related formats

Sources

Details on this page were checked against authoritative references. How sources are ranked and what is deliberately left out is set out in the methodology.