Convert a message between binary, text, or JSON


$ buf convert <input> [flags]


Use an input proto to interpret a proto/json message and convert it to a different format.


$ buf convert <input> --type=<type> --from=<payload> --to=<output>

The <input> can be a local .proto file, binary output of "buf build", bsr module or local buf module:

$ buf convert example.proto --type=Foo.proto --from=payload.json --to=output.binpb

All of <input>, "--from" and "to" accept formatting options:

$ buf convert example.proto#format=binpb --type=buf.Foo --from=payload#format=json --to=out#format=json

Both <input> and "--from" accept stdin redirecting:

$ buf convert <(buf build -o -)#format=binpb --type=foo.Bar --from=<(echo "{\"one\":\"55\"}")#format=json

Redirect from stdin to --from:

$ echo "{\"one\":\"55\"}" | buf convert buf.proto --type buf.Foo --from -#format=json

Redirect from stdin to <input>:

$ buf build -o - | buf convert -#format=binpb --type buf.Foo --from=payload.json

Use a module on the bsr:

$ buf convert <> --type buf.Foo --from=payload.json


--error-format string

The format for build errors printed to stderr. Must be one of [text,json,msvs,junit,github-actions]

--from string

The location of the payload to be converted. Supported formats are [binpb,json,txtpb]

-h, --help

help for convert

--to string

The output location of the conversion. Supported formats are [binpb,json,txtpb]

--type string

The full type name of the message within the input (e.g.

Flags inherited from parent commands


Turn on debug logging

--log-format string

The log format [text,color,json]

--timeout duration

The duration until timing out, setting it to zero means no timeout

-v, --verbose

Turn on verbose mode

Parent Command

  • buf - The Buf CLI