Protobuf .proto to TypeScript Interfaces & Enums Converter

Protobuf .proto to TypeScript Interfaces & Enums Converter

Parse Protocol Buffers (proto2 & proto3) message definitions, enums, and nested fields into clean TypeScript interfaces.

Presets:
Protocol Buffers (.proto) Schema
proto3
/**
 * Generated by ToolsAA Protobuf to TypeScript Converter
 * Syntax: proto3 | Package: identity.v1
 * 100% Client-Side Pure Execution
 */

export enum AccountStatus {
  ACCOUNT_STATUS_UNSPECIFIED = 0,
  ACCOUNT_STATUS_ACTIVE = 1,
  ACCOUNT_STATUS_PENDING_VERIFY = 2,
  ACCOUNT_STATUS_SUSPENDED = 3,
  ACCOUNT_STATUS_ARCHIVED = 4
}

export type UserProfileAuthCredential =
  | { case: 'passwordHash'; value: string }
  | { case: 'oauthProviderId'; value: string }
  | { case: 'webauthnPublicKey'; value: Uint8Array }
  | { case: undefined; value?: undefined };

export interface UserProfile {
  /** @field 6 */
  metadata: Record<string, string>;
  /** @field 1 */
  userId: string;
  /** @field 2 */
  email: string;
  /** @field 3 */
  displayName?: string;
  /** @field 4 */
  status?: AccountStatus;
  /** @field 5 */
  roles: string[];
  /** @field 7 */
  createdAt: string;
  /** @field 8 */
  lastLoginAt: string;
  /** @oneof auth_credential */
  authCredential?: UserProfileAuthCredential;
}

export interface GetUserRequest {
  /** @field 1 */
  userId: string;
}

export interface ListUsersRequest {
  /** @field 1 */
  pageSize: number;
  /** @field 2 */
  pageToken: string;
}

export interface UpdateUserRequest {
  /** @field 1 */
  user?: UserProfile;
}
Proto AST Parse Engine

Client-side lexical scanner supporting proto2 and proto3 syntax trees without server round-trips

Dual Serialization Modes

Outputs native TypeScript interfaces, enums, discriminated oneof unions, and runtime Zod validation schemas

Zero-Copy Privacy Shield

100% in-browser evaluation; proprietary schemas and internal enterprise contracts never leave your device

Native Proto3 & Proto2 AST Compiler

Client-side lexical parsing transforms messages, enums, nested types, and package namespaces into clean TypeScript declarations with strict type-safety.

Zero Data Transmission & Privacy Shield

100% browser-based conversion guarantees proprietary gRPC schemas and internal enterprise contracts never touch remote servers or third-party networks.

Production Code Gen with gRPC & Zod Ecosystem

Generates export-ready .ts files with JSDoc field numbers, configurable 64-bit integer mappings, discriminated oneof unions, and Zod runtime validators.

Technical Reference & Architecture Guide

Protobuf .proto to TypeScript Interfaces & Enums Converter — Reference Guide

Parse Protocol Buffers (proto2 & proto3) message definitions, enums, and nested fields into clean TypeScript interfaces.

Key Parameters & Controls

Field CasingEnum (camelCase | snake_case | preserve)

Naming convention for generated TypeScript interface properties. camelCase conforms to TypeScript idiomatic style and Google JSON mapping.

Default: camelCase
Declaration StyleEnum (interface | type)

Specifies whether message types are emitted as TypeScript 'interface' declarations or 'type' aliases.

Default: interface
64-Bit Integer MappingEnum (string | number | bigint)

Determines how int64, uint64, sint64, fixed64, and sfixed64 types are converted to prevent IEEE 754 precision loss beyond 2^53 - 1.

Default: string
Bytes RepresentationEnum (Uint8Array | string | Buffer)

TypeScript type mapping for Protobuf 'bytes' fields across browser and Node.js runtime environments.

Default: Uint8Array
Enum Generation StyleEnum (enum | union | const_object)

Controls whether Protobuf enums are transformed into numeric TypeScript enums, string literal union types, or const objects.

Default: enum

Pro Tips & Best Practices

Oneof Discriminated Unions

Protobuf 'oneof' groups are synthesized into strict TypeScript discriminated unions, enabling exhaustive type narrowing in switch statements and preventing conflicting mutually exclusive fields.

Safe 64-bit Integer Transport

In web browsers and REST/gRPC-Web gateways, map 64-bit integers (int64, uint64) to 'string' or native 'bigint'. Standard JavaScript 'number' silently truncates values beyond 9,007,199,254,740,991.

Scoped Nested Messages

Nested message types declared within outer messages are generated as scoped TypeScript namespaces or prefixed interface names (e.g., User_Address), maintaining modular isolation without global namespace pollution.

Runtime Validation with Zod

Pair TypeScript interface output with the generated Zod schemas to perform bidirectional runtime validation on untrusted incoming JSON payloads from gRPC-Web and REST endpoints.

Common Gotchas & Troubleshooting

Syntax error: Missing syntax declaration header

Prepend an explicit syntax declaration line at the very top of your .proto file (e.g., syntax = "proto3";). Comments or empty lines are allowed before the declaration.

Unresolved message or imported type dependency

Ensure all referenced message, enum, or imported types (like google.protobuf.Timestamp) are defined within the editor or use standard well-known types.

Duplicate field numbers / tags detected inside message

Protocol Buffers require each field inside a message to possess a unique positive integer tag (1 through 536,870,911, excluding reserved ranges 19000-19999). Renumber conflicting fields.

Frequently Asked Questions

How does this converter handle Protobuf proto3 vs proto2 syntax?▼

The parser handles both specifications. In proto3, all scalar fields are optional by default and lack field presence unless declared with the 'optional' keyword. In proto2, 'required' and 'optional' labels are strictly enforced in generated TypeScript typings.

How are google.protobuf.Timestamp and Well-Known Types represented?▼

Google Well-Known Types (google.protobuf.Timestamp, Duration, Struct, Any, StringValue) are automatically mapped to idiomatic TypeScript types (such as string | Date for Timestamp, or Record<string, unknown> for Struct).

Can I generate gRPC service client and server signatures?▼

Yes. Service definitions with rpc methods are parsed to produce unary, client-streaming, server-streaming, and bidirectional streaming method interface contracts compatible with modern gRPC and Connect-Web clients.

Is my proprietary .proto schema code sent to any server?▼

No. The entire lexical parsing, abstract syntax tree (AST) construction, and TypeScript code emission occur 100% locally in your browser's JavaScript engine. No schema data is ever transmitted across the network.

How are Protobuf repeated and map fields converted to TypeScript?▼

'repeated' fields are converted directly to array types (e.g., string[]), and 'map<string, T>' fields are converted to typed dictionaries (Record<string, T>).

Related Tools & Utilities

All Tools →