All Tools View Categories About Contact Privacy

JSON to Protobuf

Encode a JSON document into the protobuf binary wire format — no .proto schema needed.

Everything runs locally in your browser — your JSON never leaves this page.
Field numbers are assigned automatically in key order, starting at 1. Integers and booleans become varints, floats become fixed64, strings and nested objects become length-delimited fields.

Encoding rules (schema-less)

JSON valueWire typeEncoding
true / false0 (varint)01 / 00
420 (varint)2A
-10 (varint)10-byte two's complement
3.141 (64-bit)little-endian float64
"text"2 (length-delimited)key + varint len + UTF-8
[ ... ]repeatedeach element with the same field number
{ ... }2 (embedded message)recursive encode, length-prefixed
nullfield omitted

About JSON to Protobuf

Protobuf payloads are compact and fast, but writing the wire format by hand is fiddly: varint keys, base-128 encoding, length prefixes. JSON to Protobuf encodes a JSON document into the protobuf binary wire format without needing a .proto schema — ideal for building test payloads, verifying serializers and generating fixtures.

Features

  • No schema needed: Field numbers are assigned in key order.
  • Correct varints: Keys, lengths and integers use base-128 encoding.
  • Negative integers: Standard 10-byte two's complement varint.
  • Repeated fields: Arrays map to proto3 repeated semantics.
  • Embedded messages: Nested objects become length-delimited messages.
  • Three outputs: hex, base64 and a downloadable .bin file.
  • Private: All encoding happens in your browser.

How to Use

  1. Paste your JSON into the input box (or load the sample).
  2. Encode and review the hex output.
  3. Check the byte count and the field summary.
  4. Download the .bin file if you need the raw bytes.

Examples

Example 1 — Test fixtures. An engineer generates protobuf wire bytes from readable JSON to feed into unit tests of a serializer.

Example 2 — gRPC debugging. A developer encodes a request payload to compare against a captured stream in Wireshark.

Example 3 — Server mocks. A backend engineer creates binary fixtures for load tests without writing a protoc build step.

Example 4 — Learning the format. A student encodes sample documents to see exactly how varint keys and length prefixes look.

Benefits

  • Instant: Encoding happens in the browser in milliseconds.
  • Schema-less: No .proto compilation required.
  • Correct: Standard wire types and varint rules.
  • Inspectable: See every byte in hex.
  • Zero upload: Data never leaves your machine.

Frequently Asked Questions

How can JSON be encoded as protobuf without a .proto schema?
Generic encoding assigns field numbers automatically in key order (1, 2, 3, …). Strings and embedded objects become length-delimited fields, booleans and integers become varints, and floats become fixed64. The wire types are therefore deterministic; only the numeric interpretation depends on your schema.
Which wire types are used?
Wire type 0 (varint) for booleans and integers, wire type 1 (64-bit) for floating point numbers, and wire type 2 (length-delimited) for strings, arrays and nested objects. Negative integers use the standard 10-byte two's complement varint.
How are arrays encoded?
Arrays become repeated fields: every element is written with the same field number, exactly like proto3 repeated fields.
How are nested objects encoded?
As embedded messages: the inner object is encoded recursively and written as a length-delimited field, like a proto3 message-typed field.
Which output formats are available?
Hexadecimal text, base64 text, and a downloadable .bin file containing the exact bytes.
Is my JSON uploaded anywhere?
No. Encoding happens entirely in your browser. Nothing is uploaded, stored or logged.