JSON to TypeScript
Infers TypeScript interfaces or types from a JSON sample, merging optional and union fields.
Paste a JSON response and get TypeScript interfaces for it. The inference merges every record in the sample rather than reading the first one, so a field that only appears in some of them comes out optional instead of required — which is the difference between a type that compiles and a type that is true.
Sample JSON
Drop a .json file
Read in this tab. Nothing is uploaded.
Give it every element you have. Every extra record narrows the guess — a field missing from one of them is what makes it optional.
TypeScript
How to use it
Paste as many records as you have
Every element of every array is read and merged, not just the first. Three records tell it far more than one, because a field missing from one of them is exactly what makes that field optional.
Name the root type
Nested objects are named after the key that holds them, singularised for arrays, so `users` yields a `User`. Only the root needs a name from you.
Read the counts under the output
Types, optional fields, unions and how many records were merged. A union count above zero means a field held two different kinds of value across your sample — worth looking at before you paste the result into a codebase.
Copy the interfaces out
The output is a set of exported interfaces in declaration order, ready to paste into a `.d.ts` or next to the fetch that returns them.
Common questions
Is this a validator?
No. TypeScript types are erased at build time, so nothing here checks the response at runtime — a server that changes its shape will hand you a value that lies about its type. If you need the check to happen, emit Zod from the same screen and parse with it.
Why is a field typed `string` when it is a date?
Because in JSON it is a string. The inference is structural — it reports what the values are, and does not guess that an ISO-8601-looking string should become a `Date`. Narrowing that is a decision about your codebase, not about the sample.
What if a field is sometimes a string and sometimes a number?
It becomes a union, `string | number`, and the union count at the bottom goes up. That is usually a signal about the API rather than about the type — a field that changes kind is a bug waiting somewhere downstream.
Are literal types produced from the sample?
No — a `status` that is always `"active"` in three records still comes out as `string`. Three records are not evidence of an enum, and a literal type inferred from too little data is the kind of thing that breaks a build a week later.
Feed it from
Case Converter
Converts between UPPER, lower, Title, Sentence, camelCase, snake_case, kebab-case and CONSTANT_CASE.
JSON Formatter & Validator
Pretty-prints, minifies and validates JSON, pointing at the exact line and column of a syntax error.
JSON to Go Structs
Generates Go structs with json tags from a JSON sample, including nested and repeated types.
JSON to Rust Structs
Generates serde-annotated Rust structs from a JSON sample, with Option for nullable or missing fields and snake_case renames.
Next
These accept what this tool produces, so the result can go straight in.
JSON Formatter & Validator
Pretty-prints, minifies and validates JSON, pointing at the exact line and column of a syntax error.
JSON to Go Structs
Generates Go structs with json tags from a JSON sample, including nested and repeated types.
JSON to JSON Schema
Infers a JSON Schema from one or several samples, unioning the shapes it sees.
JSON to Zod Schema
Builds a Zod schema from a JSON sample, with nullable, optional and enum inference.
Base64 Encoder & Decoder
Encodes and decodes Base64 and Base64URL for text or files, handling UTF-8 correctly.
curl to Code
Converts a curl command into fetch, axios, Python requests, Go, PHP or PowerShell.