sample-driven · three targets

JSON to code

Paste a sample and get TypeScript interfaces, Python TypedDicts or a Go struct — from the shape you actually have.

0 characters

Your JSON is parsed in this tab. API samples often carry tokens and emails, so nothing is uploaded.

Short answer: paste the JSON, pick a language, copy the declarations. Nested objects become their own types; arrays merge their elements; invalid JSON is refused with the parser’s message.

What the generator decides for you

What it will not invent

Optionals, unions, date formats and enums. Each of those needs a second sample or a spec, and guessing produces code that compiles and lies. If the payload has a real contract, write it as JSON Schema and check documents against it with theJSON Schema validator.

Type generation questions

Does the output describe my real API contract?

No, and no generator can: it describes the sample you pasted. A field that never appeared cannot appear in the types, and a field that is always the same string is still typed as string. Treat the output as a starting point and keep the optional fields visible in review.

How are arrays handled?

Every element of an array is merged into one shape, so [{a: 1}, {a: 2, b: "x"}] keeps b. An empty array becomes unknown[] (or list[Any] / []any) because there is nothing to infer from — that is stated rather than filled in with a guess.

Why is a null field typed as null?

Because the sample said null. Marking it optional would be a guess about a different document. If the field is nullable in reality, change it to `string | null` — the generator will not pretend to know.

Is my JSON uploaded?

No. The conversion happens in this tab. API samples routinely contain tokens, email addresses and internal ids, so nothing is sent anywhere or stored.

Related tools