TypeScript Interface to JSON Sample

Paste a TypeScript interface or type alias on the left and a sample JSON conforming to it appears on the right. Field-name aware (id / email / name / url / *At date keys produce realistic values), handles primitives, arrays, nested objects, optionals, unions, literal types, and local refs to other interfaces in the same paste.

TypeScript input parsed
JSON sample output

      
    

About this conversion

The reverse direction of a JSON-to-TypeScript converter: you have a type, you need a sample. Common needs — a fixture for a unit test, a mock body for a Postman/Insomnia collection, a seed for a Storybook story, a placeholder response for a frontend that's ahead of the backend, an example payload to attach to a bug report. Quicktype.io covers this as a side-feature; json2ts.com / transform.tools / the json-to-ts npm CLI do not. The page is a clean wedge for the keyword cluster typescript-to-json / interface-to-mock-data / type-to-sample-json.

What it handles: primitives (string, number, boolean, null), arrays (T[], Array<T>, ReadonlyArray<T>), tuples ([T1, T2]), nested object literals, declared interfaces and type aliases (referenced by name from inside other types), optional properties (key?:), union types (the first non-null member is sampled), intersection types (object members are merged), string- and number-literal types (the literal value is emitted), and Record<K, V> + index signatures (two example keys are emitted). Date is sampled as an ISO 8601 string. any/unknown/never/void sample as null. Field-name heuristics turn id-like / email / name / url / *At keys into realistic values so the output is presentable as a fixture, not just shape-correct.

Out of scope by design: type composition you'd need a real TypeScript compiler for — generic parameter substitution beyond Array/ReadonlyArray/Record/Partial/Readonly/Required, conditional types, mapped types, template-literal types, namespace declarations, declaration merging across files. Paste the resolved shape (the way you'd write it after a hover-preview in your editor) and the output is exact. The conversion is pure client-side JavaScript — your TypeScript stays in your browser tab, nothing is uploaded, no signup. For the forward direction (paste JSON, get a TypeScript interface), use the homepage converter; for the same direction across many JSON shapes, see the long-tail landing pages linked below.

Forward direction — paste JSON, get a TypeScript interface