JSON to TypeScript

Generate TypeScript, Zod, Go, Python or PHP models from a JSON or CSV sample.

Inputs stay on your device No sign-up Free to use
How this works

The tool runs in this browser. Your file or text is not uploaded to UseFreeTools. Check this tool's limits for anything it may save on your device.

Privacy details

Generate models controls

Showing an example. Edit to see your own.

Paste one JSON value, or a CSV table with a header row. The types describe only what this sample shows.

Used for the first type; nested types are named after it.

Detect automatically reads text that starts with { or [ as JSON and anything else as CSV.

Used when the sample is read as CSV.

Each output names its own types. A CSV sample is read as text, so its columns become strings in every target.

Used by the TypeScript output only.

Used by the TypeScript and Zod outputs only.

Keeping them is the default, so the type matches the sample. The optional setting makes a key the sample showed as null optional and drops the null from the type instead. The sample alone cannot say which of the two fits the real data.

Processed in your browser. Your inputs stay on this device.

How to use JSON to TypeScript

  1. Paste one JSON value or CSV sample and select its input format.
  2. Choose TypeScript, Zod, Go, Python or PHP, name the top model and choose how nulls are handled.
  3. Inspect the inferred fields, copy the models and check them against the real data.

Example: JSON to TypeScript

Infer types from a small order sample where one order carries an extra note.

You add
{"id": 1, "name": "Ada", "tags": ["math"], "orders": [{"id": 1, "total": 19.99}, {"id": 2, "total": 5.5, "note": "gift"}]}
You get
The output has an interface Root with id: number, name: string, tags: string[] and orders: RootOrders[]. The RootOrders interface marks note as optional because only one order in the sample has it.

Options

Arrays
Every item in an array is read and the types are joined into a union. Object items are merged, so a key that appears in only some items becomes optional. An empty array becomes unknown[] because nothing inside it can be read.
Null and mixed values
A null becomes part of a union, so a nickname that is null in the sample is written as string | null when a string also appears. Every JSON number becomes number, because JSON has one numeric type.
Names and style
The top name is used for the first type, and a nested type is named after that type and the property it came from. Interfaces and type aliases carry the same fields.
Input and target
Choose JSON or CSV and the target language. CSV values stay strings, including IDs with leading zeroes. TypeScript style and export controls apply only to their supported targets. Generated models describe the sample, so check them against real records before using them.

Supported inputs and limits

Samples are limited to 1,000,000 characters, 30 levels and 200 named types. CSV allows 10,000 rows and 100 columns, with text cells; use JSON to infer numbers, booleans or nulls. Only observed values are inferred. Preserve nulls by default, or explicitly turn them into optional properties. Dates remain strings. Mixed types may become any in Go or mixed in PHP. Unsupported Go JSON keys or PHP property names are refused rather than guessed. Python output uses TypedDict and NotRequired, requiring Python 3.11 or later. Zod output requires Zod in your own project; this page does not install it or validate your API.

Where your input is processed

This tool processes your input in this browser. Your text and files are not uploaded to UseFreeTools. Check this tool's limits for anything it may save on your device.

A sample is evidence, not a schema

Types inferred from one response describe that response only. A field that is absent from the whole sample, a value that is null only on other records, or a number that arrives as a string from another endpoint will not appear in the output. Treat the result as a starting point: check it against the real records, then tighten the optional flags and unions by hand.

Questions about JSON to TypeScript

Why is a property marked optional?

It appeared in some items of an array and not others. Marking it optional keeps the type true for every item in the sample, and you can tighten it later once the real records are known.

Why is my date a string?

JSON has no date type, so a date arrives as text. The converter writes string and leaves the conversion to your own code.

What happens with an empty array?

There are no items to infer from, so the target uses its unknown or generic collection type. PHP needs at least one object to generate a class.

Does this call my API or upload my data?

No. The sample is parsed and converted in this browser. This page does not call your API or upload the sample.

Project manager: Tony Hines · Content updated 30 September 2026 · Report a problem