JSON to Types & Models Generator

Turn JSON into production-ready typed models across 8 programming languages.

InputValid
Runs in your browser8 languagesNo signup

A JSON to type converter that writes the models you would have typed by hand

This JSON to type converter reads one sample response and writes the matching TypeScript interfaces, Java and C# classes, Go structs, Python models, Kotlin classes, Rust structs or Swift types. Paste the payload, pick a language, copy the result. It is for developers who are tired of retyping field names from API docs.

Everything runs in your browser. Nothing is uploaded, so a response with real customer records or internal field names stays on your machine. Nested objects get their own named types, arrays of objects are merged so missing keys become optional, and strings that look like dates or emails get a short comment instead of a risky type guess.

  • Frontend developers

    Type a REST response before you write the first fetch call.

  • Backend developers

    Draft request and response classes for a new endpoint.

  • Mobile developers

    Get Swift and Kotlin models from the backend team's example payload.

input.json
{
  "id": 1,
  "title": "Portfolio",
  "tags": ["web"]
}
Project.ts
export interface Project {
  id: number;
  title: string;
  tags: string[];
}

02How to use

Three steps, about a minute

  1. Step 1

    Paste your JSON

    Drop in a response from your network tab, Postman or the API docs, or press Sample. The Valid badge flags errors as you type.

    SampleFormat
  2. Step 2

    Pick a language

    Choose one of eight tabs. Rename Root if you like, and switch on All optional or Readonly when you need them.

    RootAll optionalReadonly
  3. Step 3

    Copy or download

    Copy code goes to your clipboard. Download saves a file such as Root.ts or Root.kt.

    Copy codeDownload

03Why it matters

Types are a contract with someone else’s API

Generating that contract from a real response keeps it honest. You describe what the server actually sends, not what you remember from the docs.

One limit worth knowing: types are checked when you build, not when data arrives. For untrusted input, add a runtime validator on top.

  • 01

    Typos fail early

    Misspell createdAt as createAt and the compiler tells you straight away, instead of a user finding a blank value on screen.

  • 02

    Autocomplete that knows the payload

    Once the model exists, your editor suggests real field names and shows which ones can be missing.

  • 03

    Safer refactors

    When the API changes, update the sample, regenerate, and the compiler lists every place that needs attention.

04Real-world examples

Where developers actually reach for it

Five situations where pasting a sample beats typing models by hand.

TypeScript

Typing a REST client

A payment or shipping API hands you a response with forty fields and three levels of nesting. Paste it once and each nested object becomes its own exported interface, so your fetch wrapper is typed before you write the call.

"address": { "city": "Ahmedabad" }

address: Address;

Java and C#

DTOs for a new service

Start a Spring or ASP.NET endpoint from a sample request body. Property names follow each language's casing, and a rename attribute appears only where the JSON key had to change.

"first_name": "Sam"

FirstName + rename attribute

Swift and Kotlin

Models for a mobile screen

The backend team drops an example payload in chat. Generate the Swift side and the Kotlin side from the same paste.

"skills": ["React", "Node"]

[String] | List<String>

Any language

Reading a payload you did not design

Debugging a webhook with a wall of minified JSON? The generated type shows the real shape in seconds.

"total": 42.5

total: number;

Rust and Python

Learning typed languages side by side

Flip between tabs to see how null, lists and decimals map across languages.

"nickname": null

Option<T> | Optional[T]

05Type mapping

How one JSON value looks in every language

Pick a language to light up its column. Every value stays visible, so you can compare all eight at a glance.

Text

TypeScript
string
Java
String
C#
string
Go
string
Python
str
Kotlin
String
Rust
String
Swift
String

Whole number

TypeScript
number
Java
Integer
C#
int
Go
int
Python
int
Kotlin
Int
Rust
i64
Swift
Int

Decimal

TypeScript
number
Java
Double
C#
double
Go
float64
Python
float
Kotlin
Double
Rust
f64
Swift
Double

True / false

TypeScript
boolean
Java
Boolean
C#
bool
Go
bool
Python
bool
Kotlin
Boolean
Rust
bool
Swift
Bool

List

TypeScript
T[]
Java
List<T>
C#
List<T>
Go
[]T
Python
List[T]
Kotlin
List<T>
Rust
Vec<T>
Swift
[T]

Optional

TypeScript
T?
Java
T (nullable)
C#
T?
Go
*T
Python
Optional[T]
Kotlin
T?
Rust
Option<T>
Swift
T?

06Under the hood

Four rules the generator follows

The output is predictable because the rules are simple. Here they are, with a sample that triggers all of them.

  1. 01

    Null means optional

    A field that is literally null in your sample becomes optional in the generated type.

  2. 02

    Arrays are merged

    In an array of objects, every key from every item is collected. A key missing from any item is marked optional.

  3. 03

    Formats are hints

    Email, URL, UUID and ISO 8601 strings stay plain strings and get a one-line comment, so a wrong guess never breaks a build.

  4. 04

    Same shape, one type

    Objects with identical field names and types share one definition, at any depth.

sample.json
{
  "email": "sam@example.com",
  "createdAt": "2024-01-15T09:30:00Z",
  "isVerified": true,
  "tags": ["beta", "early-access"],
  "orders": [
    { "id": 1, "total": 42.5 },
    { "id": 2, "total": 10, "refunded": true }
  ]
}
TypeScript output
export interface Root {
  /** email address */
  email: string;
  /** ISO 8601 date-time */
  createdAt: string;
  isVerified: boolean;
  tags: string[];
  orders: Order[];
}

export interface Order {
  id: number;
  total: number;
  refunded?: boolean;
}

Notice that refunded appears on only one order, so it is optional, and that both order objects collapse into a single Order type. Exact output can vary slightly with your Root name and option toggles.

07Better results

Six habits that give you cleaner models

The converter can only describe what it sees. A better sample gives you a better type.

Paste a real response, not a trimmed one
Any field you delete from the sample will be missing from the model.
Include several items in every array of objects
Optional fields are found by comparing items. A single item shows only one shape.
Keep at least one item in each array
An empty array gives the converter nothing to learn the item type from.
Use a second sample when a field changes type
A value that is a number in one response and a string in another cannot be spotted from one paste.
Rename Root before you copy
Invoice or UserProfile reads far better in a codebase than Root.
Swap secrets for dummy values
Tokens and personal data do not belong in sample files you share, commit or screenshot.

08FAQ

Questions people ask before they paste

How do I convert JSON to a TypeScript interface?

Paste your JSON into the input panel and keep the TypeScript tab selected. The interfaces appear on the right, with each nested object as its own exported interface. Press Copy code and paste it into your project.

Is it safe to paste JSON with real user data or tokens?

Parsing and code generation run in your browser, so the JSON is not uploaded, logged or stored. It is still a good habit to swap live secrets for dummy values before you paste anything into any online tool.

How does the tool decide a field is optional?

A field is optional when its value is null in your sample, or when it is missing from at least one object in an array. The All optional toggle makes every field optional if you want defensive parsing.

Can I generate a Java or C# class from JSON?

Yes. Pick the Java or C# tab and you get classes with property names in that language's casing. When the converted name differs from the JSON key, a rename attribute such as JsonPropertyName is added.

What do the Python, Rust, Swift and Kotlin outputs look like?

Python output uses Pydantic models. Rust output includes serde derives with Option<T> and Vec<T>. Swift output is Codable and adds CodingKeys only when a key needs renaming, and Kotlin uses SerialName under the same rule.

Do generated TypeScript interfaces validate data at runtime?

No. Interfaces exist only at compile time, so they cannot reject a bad response. If the data comes from an untrusted source, pair the generated model with a runtime validator such as Zod and use the interface to describe the shape you expect.

Can I trust the generated types in production?

Treat them as a strong first draft. One sample cannot reveal a field that sometimes returns a string and sometimes a number, or rules your backend enforces. Check the output against the API docs or a second response before you ship.

Does the converter need an internet connection?

Conversion happens in your browser, so no request is made when you paste JSON. The page itself still has to load once, after which you can switch languages and copy results without any further network traffic.

Your JSON never leaves this tab. Press Sample at the top of the page and watch all eight languages fill in from a single paste.

UntangleTools Logo
UntangleTools Logo
UntangleTools Logo