SyntaxSnap

tRPC to OpenAPI Converter

Bridge the gap between internal speed and external documentation. Transform your tRPC routers into standard OpenAPI 3.1.0 specifications.

tRPC Router Input
OpenAPI 3.1.0 JSON
{
  "openapi": "3.1.0",
  "info": {
    "title": "tRPC Converted API",
    "version": "1.0.0",
    "description": "Auto-generated from tRPC router definition."
  },
  "servers": [
    {
      "url": "http://localhost:3000",
      "description": "Local dev server"
    }
  ],
  "tags": [
    {
      "name": "Queries",
      "description": "Read operations (HTTP GET)"
    },
    {
      "name": "Mutations",
      "description": "Write operations (HTTP POST)"
    }
  ],
  "paths": {
    "/trpc/getUser": {
      "get": {
        "summary": "Get User",
        "operationId": "getUser",
        "tags": [
          "Queries"
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          }
        },
        "parameters": [
          {
            "name": "input",
            "in": "query",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "required": [
                "id"
              ]
            },
            "style": "deepObject",
            "explode": true
          }
        ]
      }
    },
    "/trpc/listUsers": {
      "get": {
        "summary": "List Users",
        "operationId": "listUsers",
        "tags": [
          "Queries"
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          }
        }
      }
    },
    "/trpc/createUser": {
      "post": {
        "summary": "Create User",
        "operationId": "createUser",
        "tags": [
          "Mutations"
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "age": {
                    "type": "integer",
                    "minimum": 18
                  }
                },
                "required": [
                  "name",
                  "email"
                ]
              }
            }
          }
        }
      }
    },
    "/trpc/deleteUser": {
      "post": {
        "summary": "Delete User",
        "operationId": "deleteUser",
        "tags": [
          "Mutations"
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  }
                },
                "required": [
                  "id"
                ]
              }
            }
          }
        }
      }
    }
  }
}

Why convert tRPC to OpenAPI?

tRPC provides an incredible developer experience for internal monorepos, allowing you to share types between your client and server without code generation. However, when you need to expose a public API to third-party developers, they expect a standard REST interface documented with Swagger / OpenAPI.

Instead of manually maintaining a separate OpenAPI specification or rewriting your application in NestJS or Express, this tool analyzes your tRPC router definition and its underlying Zod schemas, automatically compiling them into a compliant openapi.json file ready for Swagger UI.

Explore More Developer Tools

Boost your productivity with our other privacy-first utilities.

View all Developer tools →

Popular Developer Tools