Schema to TypeScript
Generate TypeScript types from JSON Schema, or infer them from a JSON sample.
- Your draft is kept in this tab's session storage and cleared when the tab closes.
Draft kept in this tab
Your draft is kept in this tab's session storage and cleared when the tab closes. - Processing happens in this page. No application server receives your input.
Runs in your browser
Processing happens in this page. No application server receives your input.
JSON Schema or JSON sample input
Generated TypeScript output
Conversion details
- Root type
- Root
- Style
- interface
- Declared types
- None
- Execution
- In-page
What this tool does
Converts a JSON Schema object, a plain JSON sample, or an OpenAPI components.schemas document into TypeScript interface or type declarations entirely locally. The input is parsed strictly as JSON data and never evaluated.
Conversion rules
- Valid JSON Schema object: emits one exported interface (or type alias) per named subschema and root object.
- Plain JSON sample (no $schema or schema keywords): infers property types widened to string, number, boolean, null, and array item types.
- Self-referential $ref cycle: resolves internal #/... JSON Pointers and emits recursive named types without infinite recursion.
- Property identifiers: valid TypeScript identifiers are emitted bare; non-identifier or hostile property keys (such as keys containing <script>) are safely single-quoted and escaped.
- additionalProperties: false emits an exact object body; true emits [key: string]: unknown; a subschema emits a typed index signature.
- Empty or whitespace-only input is the neutral cleared state and produces empty output with no error (GAP-013).
Operational limits & execution
Maximum input size: 1.0 MB (returns InputTooLarge above cap). Maximum schema or sample nesting depth: 64 levels (returns DepthExceeded naming the offending path). Unresolved internal or external $ref pointers return UnresolvedRef naming the pointer. Execution runs in-page below 256.0 KB and offloads to codegen.worker.ts at or above 256.0 KB with cooperative cancellation.
Worked example
Input:
{"type":"object","properties":{"id":{"type":"string"}},"required":["id"]}Expected output:
export interface Root {
id: string;
}Scope: this covers the page itself. Your browser, operating system, clipboard, downloads, extensions, and crash recovery may keep copies, and a compromised site origin would not be protected.