LocalFirstTools.com — data tools that never leave your device
No upload — everything runs on your device

JSON → TypeScript

Generate TypeScript interfaces from a JSON sample. Nothing is uploaded.

The JSON → TypeScript generator infers interfaces from a pasted sample and merges array element shapes into one type — inference runs entirely in the browser.

Press Generate to derive interfaces from the JSON

What does the JSON → TS do?

This generator turns a JSON sample — an API response, a config file, a fixture — into TypeScript interfaces you can paste straight into your code. Nested objects become their own named interfaces, and arrays of objects are merged into a single element type.

How does the JSON → TS work?

The JSON is parsed with your browser's JSON.parse, then the json-to-ts library walks the value and emits one interface per distinct object shape, starting from the root name you choose. Every step runs locally in this tab; the sample never leaves your device.

Does this upload my JSON?

No. This page never sends your input to a server — formatting, decoding and hashing all run in this tab, on this device.How that works.

Frequently asked questions

How are arrays of objects typed?

All elements of an array are merged into one interface. A property present in every element keeps its type, a property missing from some elements becomes optional (marked with ?), and the same property with different types across elements becomes a union like number | string. That is why a sessions array whose items differ produces an interface with optional members.

Why are some properties optional when my API always sends them?

The generator only sees the sample you paste. If a property is absent from one array element in the sample, it is typed as optional. Feed it a sample where every element carries the property, or remove the ? by hand when you know the API guarantees it.

Why can't I generate types for a plain string or number?

Interfaces describe object shapes. The underlying library accepts a JSON object or an array of objects; a bare string, number, boolean or mixed array has no members to describe, so the tool shows an error instead. For those, a plain type alias like type Root = string is all you need.

Is null handled?

A property that is null in the sample is typed as null, because null is all the sample proves. If the field is really a nullable string, widen it to string | null yourself.

Does my JSON get uploaded?

No. Parsing and interface generation run entirely in this tab — LocalFirstTools has no server that receives your sample, which matters when it comes from a production API response.

Related tools

Browse alljson toolsor thefull tool directory.