Free · No signup · Runs in your browser

JSON to TypeScriptTypes

Paste a JSON sample and get clean TypeScript interface declarations — nested objects, typed arrays, and nullable fields included, all generated locally in your browser.

01 · How it works

Three steps, then done.

Drop in a representative JSON value and the tool walks its shape, emitting one interface per nested object and unifying array element types. Tune the root name and toggle export and readonly to match your codebase.

1

Paste a JSON sample

Provide a single representative object, an array of records, or any valid JSON value. The more complete your sample, the more accurate the inferred types — include rows that exercise every optional field.

2

Name the root and set options

Choose the root interface name (defaults to Root). Toggle the export keyword on for module-friendly declarations, and turn on readonly if your properties should be immutable.

3

Copy or download the .ts

Each nested object becomes its own PascalCase interface and arrays resolve to typed element arrays. Copy the result or download it as a .ts file and drop it straight into your project.

02 · Why ours

Why use thisJSON to types tool

A focused way to bootstrap accurate TypeScript definitions from real API responses or fixtures without hand-typing every field.

  • 01

    Nested objects get their own interfaces

    Every object-valued property becomes a separate named interface in PascalCase derived from its key, so deep structures stay readable instead of collapsing into one giant inline type.

  • 02

    Smart array and union inference

    Arrays of objects merge into a single element interface, mixed primitive arrays resolve to a union like (string | number)[], and empty arrays fall back to unknown[] so nothing is silently mistyped.

  • 03

    Nulls and missing keys handled

    A null value marks a property optional and nullable, and keys absent from some records in an array are flagged optional with a ?, matching how real-world payloads actually vary.

  • 04

    100% client-side

    Your JSON never leaves the browser. The inference runs as static JavaScript with no network calls, so even sensitive sample payloads stay on your machine.

"Nested objects become named interfaces, arrays infer their element types, and nulls become optional — all without your JSON ever leaving the browser."
csvtodashboard.com
03 · FAQ

json to types questions.

How are nested objects named?
Each object-valued property is turned into its own interface whose name is the PascalCase form of the key. For example an address property produces an Address interface, referenced from the parent. If two keys would collide, a numeric suffix keeps names unique.
Arrays of objects are merged into one element interface (the key is singularized for the name), so an array under tasks yields Task[]. Arrays of primitives resolve to the underlying type, mixed arrays become a parenthesized union, and empty arrays become unknown[].
A property whose sample value is null is emitted as optional and typed null. Inside an array of objects, a field that is null in some records and typed in others becomes a nullable union such as number | null, and is marked optional if it is missing from any record.
Yes. The export checkbox prefixes every declaration with the export keyword for module use, and the readonly checkbox marks each property readonly so the resulting types are immutable.
No. Type inference happens entirely in your browser using built-in JavaScript. Your JSON sample, the options you choose, and the generated TypeScript are never transmitted, stored, or logged.