JSON to TypeScript — Also Zod, Go, Python, Java, C#, Rust
Paste a JSON sample and get TypeScript interfaces, a Zod schema, JSON Schema or types for Go, Python, Java, C#, Kotlin, Swift and Rust.
Types are inferred from the sample only. A field that is null in your sample becomes null or any; paste a richer sample (or an array of several records) for tighter types.
Runs entirely in your browser. Your JSON is never uploaded, so it is safe for real API responses. Browse all free tools.
Found a problem, or something that could be better? We read every message and we fix things quickly.
This free JSON to TypeScript converter reads a JSON sample, such as an API response or a config file, and writes the matching TypeScript interfaces, with one named type for every nested object. The same input also produces a Zod schema, a JSON Schema, Go structs, Python dataclasses or Pydantic models, and classes for Java, C#, Kotlin, Swift and Rust, so you can stop typing out field names by hand.
Type inference uses quicktype, the open-source engine behind quicktype.io and the "Paste JSON as Code" editor extension, running in your browser. It merges every object in an array, so a field that appears in only some records becomes optional. It can only infer from what it sees: a field that is null in your sample is typed as null, and an empty array as an array of anything. Paste a sample with real values, or several records, for the most accurate types.
How to use
- Paste a JSON object or an array of objects. A sample user record is loaded to start.
- Choose the output: TypeScript interfaces, type aliases, Zod, JSON Schema, Go, Python, Java, C#, Kotlin, Swift or Rust.
- Set the root type name (for example User or OrderResponse). Nested types are named after their keys.
- Tick "Make all properties optional" for partial payloads such as PATCH bodies. Untick "Types only" to get serialization helpers where the language supports them.
- Copy the code or download it as a file with the right extension.
Frequently asked questions
How do I convert JSON to a TypeScript interface?
Paste the JSON into the box with TypeScript (interfaces) selected. Each object becomes an exported interface: strings become string, numbers number, booleans boolean, arrays T[], and nested objects get their own interface named after the key, such as address → Address. Copy the result into a .ts file and import it where you parse the response.
Should I use an interface or a type alias?
For object shapes they are almost interchangeable. Interfaces can be extended and merged by redeclaring them, and many style guides prefer them for public object types. Type aliases can also express unions and mapped types. The TypeScript (type aliases) option produces `export type User = { ... }` if your codebase prefers that style.
How are optional fields detected?
From the sample. If your JSON is an array of objects and a key is missing from some of them, that property is marked optional (name?: string). A key that is present but null in every record becomes null, and one that is a string in some records and null in others becomes null | string. To make every property optional, use the option for it.
Why use a Zod schema instead of a TypeScript interface?
An interface only exists at compile time; it cannot check that an API really returned what you expect. A Zod schema validates the data at runtime (UserSchema.parse(data) throws if a field is missing or the wrong type) and gives you the TypeScript type through z.infer, so one definition covers both. The generated Zod code exports both the schema and the inferred type.
Does it detect dates and UUIDs?
Only if you turn on "Detect dates, UUIDs and numbers in strings". It is off by default because JSON has no date type: JSON.parse returns "2026-03-14T09:26:53Z" as a string, so typing it as Date would be wrong unless you also use the generated converter. With detection on, Go gets time.Time, C# DateTimeOffset and Guid, and Python datetime and UUID.
Is my JSON uploaded?
No. The quicktype library is downloaded once (about 1 MB) and runs in your browser tab. Your JSON is never sent anywhere, so real API responses with personal data are safe to paste.
How JSON values map to each language
• Strings: string in TypeScript, Go, Swift and Kotlin (String), str in Python, String in Java and Rust, string in C#.
• Whole numbers: number in TypeScript, int64 in Go, int in Python, long in Java, Long in Kotlin, long in C#, Int in Swift, i64 in Rust. Numbers with a decimal point become float64, float or double.
• Booleans: boolean, bool, Boolean, Bool, as each language spells it.
• Arrays: T[] in TypeScript, []T in Go, List[T] or list[T] in Python, List<T> in Java, Kotlin and C#, [T] in Swift, Vec<T> in Rust.
• Nested objects: a separate named type or class. Objects with many dynamic keys (like a map of IDs) are detected and typed as a map or Record instead of hundreds of fields.
• null: null in TypeScript, interface{} in Go, None in Python, object in C#. Give the field a real value in your sample to get a useful type.
Getting accurate types from a sample
Inference is only as good as the sample. Three habits make a big difference. First, paste several records as an array rather than a single object, so optional fields and mixed types show up. Second, replace nulls with realistic values when you know the type, since a field that was null in every record gives you no information. Third, rename the root type to what the payload actually is (InvoiceResponse, not Root); nested types are named from their keys and read much better in a codebase when the root is meaningful.
If you own the API, the better long-term answer is to generate types from its schema (OpenAPI or JSON Schema) rather than from samples. The JSON Schema output here is a reasonable starting point for writing that schema.
Related free tools
- JSON Formatter — Pretty-print, minify and validate JSON, with parse errors located by line and column. In your browser, no upload.
- curl to Code — Paste a curl command, including Chrome "Copy as cURL", and get the same request in Python, JavaScript, Node, Go, PHP, Ruby, Java, C#, wget or HTTPie.
- YAML Validator — Validate YAML with the exact line and column of each error, and catch the mistakes parsers accept silently: yes/no booleans, tabs, duplicate keys.
- JWT Decoder — Decode a JWT's header and payload, read the expiry in plain language, verify HS, RS, PS and ES signatures, or sign a new token. Nothing leaves your browser.
- SQL Formatter — Format messy SQL into readable, consistently indented queries for PostgreSQL, MySQL, T-SQL, BigQuery and more. Runs in your browser.