LazyTools

🔒 Every tool runs in your browser — the files and values you enter are never uploaded to any server. How it works

🟦 JSON to TypeScript

Paste a JSON object or array and get ready-to-use TypeScript interfaces — nested shapes become their own interfaces, missing keys become optional, and mixed arrays become unions.

3 interfaces generated

Rate this tool:
Anonymous — no account, no identifier

How the json to typescript works

The generator parses your JSON and walks the structure, inferring a TypeScript type for every value: strings, numbers and booleans map directly; null becomes null; arrays become T[]; and each nested object becomes its own named interface. When an array holds objects, their keys are merged — a key missing from some elements is marked optional (?), and a key with more than one shape becomes a union. Everything runs in your browser, so API responses you paste are never uploaded.

Names are derived from your keys (an "orders" array of objects yields an Order interface, singularised and PascalCased). Because types are inferred from a sample, they reflect only what that sample contains — an always-present field that is sometimes null will be typed null; widen it by hand if it can also hold other values. Empty arrays infer any[], since there is nothing to infer an element type from.

Frequently asked questions

How do I convert JSON to a TypeScript interface?

Paste your JSON and the tool generates interfaces for it, with nested objects broken out into their own named interfaces. Copy the result straight into your .ts file. It runs locally — nothing is sent to a server.

Are optional and union types detected?

Yes. In an array of objects, a key that is absent from some elements is marked optional with ?, and a key that appears with different value types becomes a union (e.g. string | number).

Can I output type aliases instead of interfaces?

Yes — switch the Output option to "type alias" to get `type X = { … }` instead of `interface X { … }`. Both describe the same shape; pick whichever your codebase prefers.

Why is a field typed as null or any?

A field whose only sample value is null is typed null — widen it manually if it can hold other values too. Empty arrays become any[] because there is no element to infer from. Inference reflects the sample you paste, not every possible response.

Is my JSON kept private?

Yes. Parsing and generation happen entirely in your browser; the JSON you paste (which may be a real API response) never leaves your device.

Related developer tools

From the blog