TypeScript Class to JSON Schema Generator

Need JSON to TypeScript?

Transform JSON structures into TS interfaces.

JSON → TypeScript Types

TypeScript code Input

Loading...

JSON Schema Output

Paste your TypeScript types to produce JSON Schema instantly.

Supports interfaces, type aliases, public class fields, optional/readonly modifiers, and union types.

Frequently Asked Questions

What TypeScript syntax is supported?

Interfaces, type aliases, and classes with public fields are parsed. Optional properties, readonly modifiers, string-literal keys, union types, arrays, Record types, and nested references are handled. Comments and decorators are ignored so you can paste DTOs directly from your project.

How does type mapping work?

Primitive types (string, number, boolean, bigint, Date) map to JSON Schema primitives with appropriate formats. Arrays (Foo[] or Array<Foo>), Record<string, T>, and dictionary-like shapes become schema arrays/objects. Union types that include null/undefined automatically mark the field as optional.

Can I use it for classes as well as interfaces?

Yes. As long as the class defines public fields (or readonly properties) with type annotations, it will be converted into JSON Schema. The tool works entirely in your browser, so no code leaves your machine.

How do I get mock JSON from the schema?

After the schema is generated, click "Generate Mock Data" to open the Mock Generator with the schema preloaded. Configure locales, array sizes, and optional fields to produce sample payloads instantly.