JSON to TypeScript

Generate supported model types from pasted or uploaded JSON and CSV samples.

On-device No sign-up Free to use

Generate models controls

Showing an example. Edit to see your own.

Drop your CSV file here

or choose one from your device

Optional UTF-8 text up to 1,000,000 bytes. A chosen file replaces pasted text.

    ?

    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.

    ?

    Automatic reads text starting with { or [ as JSON. Otherwise, a comma or line break suggests CSV; a remaining valid JSON scalar is read as JSON and other text as CSV. Choose a format explicitly when needed.

    ?

    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.

    Result

    Showing an example.

    Infer a root model, nested address and order type from the supplied JSON records.

    Created 3 TypeScript types from a 350 character sample. A property or value type that the sample does not show cannot be inferred.

    Loading the tool. Your result will appear here.

    https://usefreetools.net/json-to-typescript · 20 November 2026

    Was this helpful?

    How to use JSON to TypeScript

    1. Paste a JSON or CSV sample, or choose one UTF-8 source file. A selected file replaces the text. Choose the input format explicitly when automatic detection does not fit.
    2. For CSV, choose a delimiter and whether the first row contains names. Cells remain strings, including IDs with leading zeroes.
    3. Choose the output target, top type name and null handling. TypeScript style applies to TypeScript; the export option applies to TypeScript and Zod.
    4. Copy the generated source and review it against other real records before adding it to a project. Supply any target-language packages or runtime your project needs.

    Example: JSON to TypeScript

    Infer a root model, nested address and order type from the supplied JSON records.

    You add
    JSON or CSV sample: { "id": 101, "name": "Ada Lovelace", "active": true, "joined": "2026-01-14", "score": 4.5, "nickname": null, "tags": ["math", "history"], "address": { "city": "London", "postcode": "SW1A 1AA" }, "orders": [ {"id": 1, "total": 19.99, "shipped": true}, {"id": 2, "total": 5.5, "shipped": false, "note": "gift"} ] }; Read the sample as: auto; The first CSV row holds the column names: true; Generate: typescript; Top type name: Root; TypeScript style: interface; Add export before each TypeScript or Zod name: true; Null values in the sample: preserve
    You get
    Created 3 TypeScript types from a 350 character sample. A property or value type that the sample does not show cannot be inferred.

    Options

    Source format
    Automatic detection treats text beginning with { or [ as JSON. Otherwise, a comma or line break suggests CSV; a remaining valid JSON scalar is read as JSON and other text as CSV. Choose JSON or CSV explicitly when needed.
    CSV columns
    With headers enabled, the first row names fields; without them, names are column_1, column_2 and so on. Empty header names receive generated names. Repeated header names produce a warning and keep the last column of that name. All cells stay strings.
    Arrays and optional fields
    The tool examines every array item, combines observed types and merges object fields. A field missing from some object items becomes optional. Empty arrays have no observed item type, so the target uses an unknown or generic collection representation.
    Null handling
    Keeping them is the default, so observed nulls remain part of the type. The optional setting makes a null-bearing property optional and removes null from its type; a null-only property has no other observed type to infer. A single sample cannot establish which policy fits every record.
    Names and output style
    The top name supplies the first model name, with names derived for nested objects. TypeScript can use interfaces or aliases. Export prefixes apply to TypeScript and Zod only. Each other target uses its own supported type syntax and naming rules.

    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.
    More details

    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.

    Selected UTF-8 files replace the sample.

    Existing TypeScript, Zod, Go, Python and PHP targets remain;

    Java, C#, Kotlin and Rust targets are not added.

    Where your input is processed

    This tool does not upload your inputs. See the limits for anything saved 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.

    Page updated · Project managed by Tony Hines · Report a problem with JSON to TypeScript

    Related reading

    All guides