JSON to CSV Converter
JSON to CSV Converter
Paste JSON and instantly generate TypeScript interfaces or type aliases with recursive type inference - free and fully in your browser.
The JSON to TypeScript Converter is a free, browser-based tool that turns any JSON object or array into ready-to-use TypeScript interfaces (or type aliases). Paste your JSON, and it recursively infers the shape of your data - typing every field, promoting nested objects into their own named interfaces, and inferring array element types - so you get static types you can drop straight into your project.
Everything runs client-side with a hand-written recursive type walker and the native JSON.parse, so no data is uploaded, there is no sign-up, and there is no dependency on an external API. Your JSON never leaves your device, which makes the tool safe for private payloads and internal API responses.
User or ApiResponse).?..ts file.The converter walks your JSON recursively and maps each value to a TypeScript type: strings become string, numbers become number, booleans become boolean, and every nested object becomes its own named interface derived from the property key. Arrays are inspected element by element - a list of strings becomes string[], while an array of objects is merged into a single interface where keys that appear in only some elements are marked optional.
When a value is null or a field holds more than one type, the tool produces a union such as string | number | null, and identical nested shapes are automatically deduplicated so the same interface is reused instead of generated twice.
An interface is the idiomatic choice for describing the shape of an object, especially when you expect to extend it or let declarations merge. A type alias is more flexible for unions, intersections, and mapped types, and many teams prefer it for API response models. This tool supports both so you can match your codebase's convention - flip the dropdown and the entire output regenerates instantly.
export, and mark nullable fields optional..ts file in one click.Generate TypeScript types when you are consuming an API and want compile-time safety around its JSON payloads. If instead you just need to tidy or validate that JSON, a dedicated JSON Formatter is the faster path, and when your target is a different data format you can reach for a JSON to XML Converter or a JSON to YAML Converter instead. If your source data starts as a spreadsheet, convert it first with a CSV to JSON Converter and then paste the result here, and when you are wiring up the request itself a cURL to Code Converter pairs neatly with the interfaces you generate.
Feed the converter a representative sample - if a field can be null or missing in real responses, include an example of that so the inferred type reflects it. For arrays of records, pass several objects rather than one, since the merge step relies on multiple samples to decide which keys are optional. Finally, give the root a meaningful name; a good root name flows into the nested interface names and keeps the output readable.
No. The conversion runs entirely in your browser using client-side JavaScript. Your JSON is parsed and typed locally and never leaves your device, so it is safe to use with private or sensitive API data.
Each nested object is promoted into its own named interface derived from the property key, and the parent interface references it by name. Identical nested shapes are detected and reused, so you get one clean interface instead of duplicated inline types.
A null value produces the type null, and if you enable the optional setting the field is marked with a question mark instead. When a field or array holds more than one type, the tool emits a union such as string | number | null.
Yes. Switch the declaration style dropdown to type and the tool emits type aliases like type User = { ... } instead of interface declarations. You can also toggle the export keyword on or off.
It merges every object in the array into a single interface. Keys present in all elements are required, while keys that appear in only some elements are marked optional, and the array itself is typed as ElementType[].
Yes. Click Download to save the generated TypeScript as a .ts file named after your root interface, or use Copy to place it on your clipboard and paste it straight into your editor.