# JSON to TypeScript

> Generate TypeScript interfaces from JSON. Runs entirely in your browser — nothing you paste is sent anywhere.

Source: https://toffeekit.com/tools/json-to-typescript

**Category:** [Developer](https://toffeekit.com/category/developer) · **Price:** Free · **Runs:** in your browser, nothing is uploaded

Open the tool: https://toffeekit.com/tools/json-to-typescript

**Also useful for:** typescript, types, interface, json

## How it works

1. Paste a sample of your JSON into the JSON box. An API response works well.
2. Set the Root type name, for example User or ApiResponse.
3. Read the generated TypeScript interfaces in the output panel.
4. Click Copy or Save to keep them as types.ts.

## FAQ

### How do I generate TypeScript types from JSON?

Paste a real example of your data. The tool creates an exported interface for the root object and one for every nested object.

### How are arrays of objects handled?

The objects in an array are merged into one interface. A key that is missing from some of the objects is marked optional with a question mark.

### What type does a null value get?

null. If a field can be either a value or null in your real data, edit the result to a union such as string | null, because one sample cannot show both.

### What happens with an empty array?

It becomes unknown[] because there is nothing to infer from. Add an item to the sample, or change the type by hand.

### Can I change the name of the main interface?

Yes. Use the Root type name field. Nested interfaces are named from their keys, such as profile becoming Profile, and numbered if names clash.

### Is JSON to TypeScript free and private?

Yes. It's free with no sign-up or limits, and it runs entirely in your browser, so what you type or paste never leaves your device. It works on phones and computers alike.

## Privacy

JSON to TypeScript runs entirely in your browser. Your files and text are processed on your device and are never uploaded.

## Related tools

- [JSON Formatter](https://toffeekit.com/tools/json-formatter) — Format, minify and validate JSON with clear errors.
- [Base64 Encode / Decode](https://toffeekit.com/tools/base64-encoder) — Encode text to Base64 or decode it back, UTF-8 safe.
- [URL Encode / Decode](https://toffeekit.com/tools/url-encoder) — Percent-encode query values or whole URLs.
- [HTML Entities](https://toffeekit.com/tools/html-entity-encoder) — Escape < > & and quotes, or decode entities.
- [JWT Decoder](https://toffeekit.com/tools/jwt-decoder) — Read a token's header, claims and expiry.
- [Hash Generator](https://toffeekit.com/tools/hash-generator) — MD5, SHA-1, SHA-256, SHA-384 and SHA-512 at once.

