Input (.proto schema)

Output (formatted .proto)

What this tool does

You paste a Protocol Buffers schema with mixed indentation, jammed-together field declarations, or random blank lines from a copy-paste, and you want it to look like the rest of the codebase. This formatter rewrites the file with two-space indentation per brace level, exactly one space around =, one space after ,, and at most one consecutive blank line between blocks. Comments — both // line comments and /* ... */ block comments — stay exactly where you put them.

It does not parse or validate the schema, which means it works on slightly-broken input the way buf format or your editor's "Format Document" might not. If your .proto has a syntax error somewhere, the rest of the file still gets formatted around it. The trade-off: it cannot reorder fields, normalize import order, or strip unused options the way a true parser-based formatter could. For that, run buf format in your build pipeline.

Everything runs in your browser — no upload, no rate limit, no schema sent anywhere. Useful when the schema contains internal package names, type names, or anything you would not want shipped to a third-party API. Works on any size file your browser can hold in memory; even tens of thousands of lines format in well under a second.

How to use it

Three steps. Output updates ~300 ms after you stop typing.

1

Paste your .proto schema

Drop the schema into the left editor. syntax, package, import directives, message blocks, nested enums, oneof, map<K, V> — all handled. Mixed line endings (CRLF) get normalized to LF on the way out.

The formatter does not reorder anything — fields, imports, and options stay in the order you wrote them. If you want canonical ordering, run buf format after.

2

Read the formatted output

On the right: the same schema, indented 2 spaces per { level. Lines starting with } dedent before emit. Multiple consecutive blank lines collapse to one. Trailing whitespace removed. Comments preserved verbatim including their relative position.

3

Use the result

Copy back into your editor or download as formatted.proto. The output is byte-for-byte equivalent to the input as far as protoc is concerned — only whitespace changes — so you can drop it back in without worrying about wire-format or generated-code differences. Verify by running protoc --descriptor_set_out=before.pb input.proto and the same on the formatted output: the descriptors will match.

When this actually saves time

Cleaning up pasted .proto from chat or docs

A teammate pastes a schema fragment in Slack, the indent is mangled, you want it in your repo. Drop it here, copy the formatted version, paste into your file. Faster than the "select all, retab" dance in your editor.

Standardising legacy .proto across an old repo

You inherited a Protobuf repo where every file uses different indentation. Run each file through this formatter, push as a single normalisation commit, then turn on buf format in CI to keep it that way.

Quickly checking a generated .proto

Some code generators (JSON Schema → Protobuf, OpenAPI → Protobuf) emit valid but ugly schemas. Format the output, eyeball it, decide whether to keep the generator or hand-edit.

When you cannot install protoc or buf

You are on a locked-down machine, on a guest network, or just reviewing a PR in the browser. The browser-only formatter gives you the same readable output without installing the Protocol Buffers toolchain.

Common questions

Is my schema sent anywhere?

No. The formatter runs entirely in your browser as JavaScript. Nothing about the schema — message names, package paths, comments — leaves your machine. Open DevTools and watch the Network tab while you paste; you will see zero requests.

Does it preserve comments?

Yes — both // single-line and /* ... */ block comments stay exactly where you put them. Comments on their own line keep their relative position; trailing comments at the end of a field line stay attached to that field. The line-based approach was chosen specifically so comments survive intact.

How is this different from buf format?

buf format parses the schema into a syntax tree and re-emits it. That gives stronger guarantees — canonical option ordering, consistent enum casing, etc. — but it requires the schema to parse cleanly. This formatter is line-based, so it works on slightly-broken input that buf would refuse, and it does not impose canonical ordering. For finished code, run buf format. For mid-edit schemas or third-party fragments, use this.

Does it change the schema semantics?

No — only whitespace changes. protoc would emit the same FileDescriptorProto from the input and the output. You can verify with protoc --descriptor_set_out=before.pb input.proto against the same on the formatted file; the binary descriptors are identical except for any source-info span changes (which are reflection metadata, not wire-format).

What about indentation width — can I change it from 2 spaces?

The output is fixed at 2 spaces per brace level, matching the convention in the official Protocol Buffers style guide. If you need 4 spaces or tabs, run the output through sed or your editor's tab-conversion. Keeping the formatter's output canonical avoids per-team config drift.

Does it handle CRLF line endings?

Yes — input CRLF (\r\n) is normalised to LF (\n) on the way out. If you need CRLF in the file you save, your editor will re-encode on save based on its line-ending setting.

Related tools

If you are working with Protobuf schemas, these pair well: