JWT to OpenAPI Schema Generator
Paste a decoded JWT JSON payload to generate an OpenAPI 3.0 Schema Object or JSON Schema. 100% client-side.
How to Use the JWT to OpenAPI Schema Generator
- Decode your JWT — use our JWT Decoder or copy the payload section directly (the middle part of the three dot-separated segments, Base64-decoded to JSON).
- Paste the payload JSON into the left panel.
- Choose your output mode — OpenAPI 3.0 YAML schema, standalone JSON Schema, or a
$refpointer for inline referencing. - Copy or download the generated schema and paste it into your API specification document.
What Is a JWT Payload?
A JSON Web Token (JWT) is composed of three Base64URL-encoded parts separated by dots: the header, the payload, and the signature. The payload is a JSON object containing claims — name/value pairs that carry information about the token subject, issuer, expiry time, and any custom application data. Common registered claims include sub (subject), iss (issuer), aud (audience), exp (expiration time), nbf (not before), and iat (issued at). Private claims are any additional fields your application needs.
Why Generate an OpenAPI Schema from a JWT Payload?
When building REST APIs that accept or return JWT claims — such as user-info endpoints, token introspection responses, or authentication request bodies — you need a machine-readable description of those fields so that API clients, SDK generators, and documentation tools can understand them. Writing OpenAPI schemas by hand for complex JWT payloads is tedious and error-prone. This tool automates type inference from a real token, saving significant time when documenting /auth/token, /userinfo, or webhook event payloads.
How Type Inference Works
Each key in the JWT payload JSON is examined using JavaScript's typeof operator and Array.isArray():
- string — maps to
type: string - number (integer) — maps to
type: integer, format: int64(standard Unix timestamps likeiat/expreceive adescriptionannotation) - number (float) — maps to
type: number, format: float - boolean — maps to
type: boolean - array — maps to
type: arraywithitemstype inferred from the first element - object — maps recursively to a nested
type: objectwithproperties - null — maps to
type: string, nullable: true
OpenAPI 3.0 vs JSON Schema
The OpenAPI 3.0 specification uses a dialect of JSON Schema Draft 07 with several differences: it uses nullable: true instead of type: ["string", "null"], does not support $schema or $id keywords, and adds proprietary extensions like discriminator and xml. The JSON Schema output mode of this tool generates a fully self-contained JSON Schema document, including a $schema declaration, suitable for use with validators like ajv or jsonschema in Python. The Reference mode generates a $ref string you can drop inline inside an OpenAPI path operation's requestBody or responses section, pointing to the schema in components/schemas/JwtPayload.
Standard JWT Claim Annotations
The following registered claim names defined in RFC 7519 are automatically annotated with descriptions when present:
sub— Subject: identifies the principal that is the subject of the JWTiss— Issuer: identifies the principal that issued the JWTaud— Audience: identifies the recipients that the JWT is intended forexp— Expiration Time: Unix timestamp after which the JWT must not be acceptednbf— Not Before: Unix timestamp before which the JWT must not be acceptediat— Issued At: Unix timestamp when the JWT was issuedjti— JWT ID: unique identifier for the token, used to prevent replay attacks
Integrating into Your OpenAPI Document
After generating the schema, paste it into the components.schemas section of your OpenAPI 3.0 YAML or JSON document. For example:
components:
schemas:
JwtPayload:
type: object
properties:
sub:
type: string
description: Subject identifier
exp:
type: integer
format: int64
description: Expiration time (Unix timestamp)
You can then reference this schema in path operations using $ref: '#/components/schemas/JwtPayload'. For more API documentation tooling, try our JSON-LD Schema Generator or JSON Formatter.