Skip to content
T
Tools.Town
Free Online Tools for Everyone
interface

JSON to TypeScript

100% Free

Turn any JSON sample into clean TypeScript interfaces or type aliases — it infers primitives, nested objects, and arrays, names every type, and runs entirely in your browser.

Type Inference
Nested Aware
Instant
100% Client-Side
Generated TypeScript
Output options

Generated 3 interfacees · runs entirely in your browser.

Embed This Tool

Easy to Embed

Add JSON to TypeScript to your website or blog in seconds.

  • Responsive design
  • Lightweight & fast
  • No backend required
  • Always up-to-date
<iframe
  src="https://tools.town/embed/json-to-typescript/"
  width="100%"
  height="600"
  style="border:none; border-radius:12px;"
  loading="lazy"
  title="JSON to TypeScript">
</iframe>

Share This Tool

Share Instantly

Share JSON to TypeScript with anyone — no login required.

  • Shareable link
  • No login required
  • Works on any device
  • No account needed

Share via

Advertisement

How to Use

  1. 1 Paste a representative JSON sample on the left
  2. 2 Set the root interface name (defaults to Root)
  3. 3 Toggle options: export, interface vs type, semicolons, unknown vs any
  4. 4 Watch the TypeScript update instantly as you type
  5. 5 Copy the generated interfaces straight into your codebase

Features

  • Infers string, number, boolean, null, object, and array types
  • Generates a named interface for every nested object
  • Merges arrays of objects and marks missing keys optional
  • Builds union element types for mixed arrays
  • Switch between interface and type alias output
  • Quotes non-identifier keys so the output always compiles

Why it Matters

Hand-writing TypeScript types for an API response is tedious and easy to get wrong, especially with deeply nested data. Generating them from a real JSON sample gives you accurate, compile-ready types in seconds — so you spend time using the data, not describing it.

★★★★★

Use Cases

Typing API Responses

Paste a real response and get types your client code can rely on

Config & Fixtures

Generate interfaces for config files and test fixtures

Migrating to TypeScript

Bootstrap types when porting a JavaScript codebase

Quick Prototyping

Sketch data shapes fast without writing types by hand

What this tool does

JSON to TypeScript turns a JSON sample into ready-to-use TypeScript. It infers the type of every field, generates a named interface for each nested object, and handles arrays — including arrays of objects, where it merges keys and marks the optional ones.

How it works

Your JSON is parsed and walked recursively. Objects become interfaces (or type aliases), arrays become element-typed arrays, and primitives map to their TypeScript equivalents. Non-identifier keys are quoted so the result always compiles, and you control the output style with the export, semicolon, and unknown-over-any toggles.

Privacy

Everything runs locally in your browser. Nothing you paste is uploaded, logged, or stored.

Frequently Asked Questions

How does it infer types from JSON?
It parses your JSON and walks the structure: objects become named interfaces, arrays become element-typed arrays, and primitives map to string, number, boolean, or null. Nested objects each get their own interface named after the key that holds them.
What happens with arrays of objects?
Objects in the same array are merged into a single interface. A key present in every element is required; a key missing from at least one element is marked optional with a question mark, so the generated type matches the real data.
Can I generate type aliases instead of interfaces?
Yes. Toggle the 'Use type alias' option to emit type X = { ... } instead of interface X { ... }. You can also turn the export keyword and semicolons on or off to match your project's style.
What about empty arrays or null values?
An empty array becomes any[] (or unknown[] if you prefer), since there are no elements to infer from. A null value is typed as null — combine the output with your own optionality rules if a field can be null or absent.
Is my JSON sent anywhere?
No. Parsing and code generation happen entirely in your browser. Nothing you paste is uploaded, logged, or stored — closing the tab clears everything.

Related Tools You Might Like

Browse more free tools