Pure Frontend · Interface Convert · Type Inference · Union Types · Multi-format Export
Zero Dependencies · Works OfflineThe TypeScript to JSON Schema tool is a pure frontend online tool for converting TypeScript type definitions into JSON Schema. It supports interface, type aliases, enum, primitive types, arrays, nested objects, union types, optional properties, and literal types. The generated JSON Schema can be used for API documentation, form validation, code generation, and more. All conversion is done locally in your browser — data is never uploaded to any server.
Step 1: Select JSON Schema version (Draft 2020-12 or Draft 7).
Step 2: Enter TypeScript type definitions in the text area, or click "Load Example".
Step 3: Click "Convert Schema" or use Ctrl+Enter to view the generated JSON Schema.
Step 4: Click "Copy Schema" to copy to clipboard, or "Download JSON" to save as a file.
Convert TypeScript interface definitions to JSON Schema for OpenAPI/Swagger documentation generation, ensuring frontend-backend type consistency.
Use JSON Schema to drive frontend form validation (e.g., ajv, jsonschema libraries), auto-generating validation rules from TypeScript types.
Generate JSON Schema from TypeScript types, then use it to generate type definitions in other languages, mock data, or documentation.
Convert config file TypeScript types to JSON Schema for validating JSON/YAML configuration files.
JSON Schema is a standard for describing JSON data structures, with the latest version being Draft 2020-12. TypeScript's type system has a natural correspondence with JSON Schema: string maps to {"type":"string"}, number maps to {"type":"number"}, interface maps to {"type":"object","properties":{...}}. Optional properties prop?: type are excluded from the required array. Union type 'a'|'b' becomes {"enum":["a","b"]}, string|number becomes {"oneOf":[{"type":"string"},{"type":"number"}]}. Array Type[] becomes {"type":"array","items":{...}}.
Supports interface, type aliases, enum, primitive types (string/number/boolean), arrays, nested objects, union types, optional properties, and literal types.
No. All TypeScript parsing and JSON Schema generation is done locally in your browser. Your data is never uploaded to any server.
Yes. Union types are converted to JSON Schema's oneOf or enum structures, e.g., type Status = 'active' | 'inactive' becomes an enum array.
Yes. Nested objects are recursively converted to JSON Schema's properties and required structures, supporting multiple nesting levels.
Default is JSON Schema Draft 2020-12, with Draft 7 also available as an option.
Yes. You can copy the JSON Schema to clipboard or download as a JSON file.