Loona Automation logoLoona Developer Tools
Home › Code Generators

JSON to TypeScript Interfaces

In short: paste a JSON object (or an array of objects) and get TypeScript interfaces — nested objects extracted as named interfaces, keys missing from some array items marked optional with ?.
🔒 Private by design: everything runs in your browser on this device. Your input is never uploaded to a server.

Example

Input:

{"name": "Ali", "age": 30, "skills": ["ts", "go"]}

Output:

interface Root {
  name: string;
  age: number;
  skills: string[];
}

About this converter

Type generation from sample JSON is inference, not mind-reading: the converter walks the value, maps JSON types to TypeScript types (numbers unify int/float into number, since JSON itself does not distinguish), extracts nested objects as their own interfaces named after their key, and — when the input is an array of objects — merges the objects, marking any key that does not appear in every item as optional. Fields that are null in the sample type as null; if your real data sometimes has a string there, widen the type. Treat the output as a strong first draft of your types: review it the way you would a colleague's pull request.

Frequently Asked Questions

Why did my integer become just "number"?

JSON has one number type; TypeScript interfaces follow it. The int/float distinction only appears in the Go output (int64/float64).

What does the ? on a field mean?

The field was absent in at least one object of the input array, so it is optional in the merged interface.

Related Developer Tools

Embed this tool on your website — free

Add this tool to your own website or blog — it is completely free, needs no sign-up, and always shows the latest version. Copy the code below and paste it into your page where you want the tool to appear. Keeping the small “Powered by Loona Automation” credit line under the embed helps keep this tool free — but you are free to style or remove it; the tool works either way.