API Toolkit

JSON to TypeScript

All tools

Turn an API response into interfaces you can import, without typing every field by hand.

How it works

Four simple steps

1

Paste a sample

Use a real response with as many fields filled as possible.

2

Interfaces are inferred

Nested objects become their own named interfaces.

3

Refine the draft

Mark optional fields and widen null types by hand.

4

Copy or download

Save the output as types.ts.

JSON to TypeScript

About JSON to TypeScript

You are wiring a third-party endpoint into a React app, and the docs only show an example response. Pasting that example here gives you interfaces to start from, so the editor can catch misspelled property names before they reach production.

The generator walks your JSON from the top. The root object becomes an exported interface named Root, and each nested object becomes its own exported interface named after its key in PascalCase, so a profile field produces a Profile interface. Strings, numbers and booleans map to string, number and boolean, null maps to the null type, and arrays take their element type from the first item, with objects inside arrays named like TagsItem. Empty arrays become unknown[]. The output refreshes as you type, and you can copy it or download it as types.ts.

Because one sample is all it sees, treat the result as a first draft. Fields that are sometimes missing are marked as always present, a value that is null in the sample becomes the null type instead of string | null, and if two different nested objects share a key name, only the first shape is kept. Feed it a response with the optional fields filled in, then add ? to optional properties yourself. For runtime checks to go with the types, generate a Zod or Valibot schema, and if the JSON is minified, expand it with the pretty-print JSON tool first.

Type inference is a small script running on this page, so private response data stays on your machine.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

Root. There is no option to rename it in the tool, so rename it after pasting, or use your editor's rename refactoring to update every reference at once.

They are turned into valid identifiers by replacing the characters with underscores, so first-name becomes first_name. That no longer matches the JSON key, so quote the property name by hand.

Yes. The interface is built from the first element and named RootItem. No wrapper type is emitted for the array itself, so declare a Root type as an array of RootItem if you need one.

View more FAQs

Related tools

View all

Webhook HMAC Signer

Sign and verify GitHub, Stripe, and Slack webhook signatures locally.

Open

Webhook Replay Diff Lab

Compare webhook payload timelines, re-check HMAC digests, and spot idempotency gaps locally.

Open

JSONPath Playground

Query JSON with JSONPath and JMESPath-style paths side by side.

Open

GraphQL Studio

Format, validate, and cost-estimate GraphQL documents with cURL export.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools