Codalyst Tech
Developer tools

Browser tool · Instant

TypeScript interface generator

Paste any JSON sample — an API response, a database record, or a config object — and get a clean TypeScript interface in seconds.

JSON input
TypeScript interface
TypeScript interface will appear here

Frequently asked questions

How does the TypeScript interface generator handle nested objects?

Each nested object becomes its own named interface. For example, if your JSON has a user object with an address object inside, the generator creates both a User interface and an Address interface, then uses Address as the type for the address field in User. You can customise the root interface name and all child interface names follow the field name with the first letter capitalised.

What happens with null values in the JSON?

Null values are ambiguous in JSON — they could mean the field is intentionally absent, or that it has no value but will always exist. The generator gives you two options: mark null fields as nullable using a union type like string | null, or mark them as optional using the ? modifier. You can also choose both. The safest default for most codebases is to use nullable types rather than optional, since it forces you to handle the null case explicitly.

Does it handle arrays of mixed types?

Arrays containing multiple types are typed as unknown[] to avoid losing type safety. If all items in the array are the same primitive type (all strings, all numbers), the generator produces the correct typed array like string[]. If items are all objects with the same shape, it generates a typed interface and uses it as InterfaceName[] for the array type.

Can I paste a real API response to generate types?

Yes, this is the primary use case. Paste the JSON response from any REST API endpoint and get TypeScript interfaces you can use directly in your frontend code. A common workflow is to paste a sample response from a tool like Postman or the browser network tab, generate the interfaces, then copy them into your codebase.

How it works

The generator recursively walks the JSON object and infers a TypeScript type for each field: string, number, or boolean for primitives, named child interfaces for nested objects, and typed arrays for JSON arrays.

Enable nullable null fields to mark fields that hold null as string | null. Enable optional null fields to additionally add a ? marker, meaning the field may be absent entirely.

Tip: the generator infers types from the first element of each array. If your array contains mixed types or the types vary, review the output before using it in production.

Building a TypeScript API or full-stack product?

Talk to Codalyst about your project