Skip to main content
OnlineTools

Runs locally in your browser

JSON to TypeScript Converter

Turn sample JSON into clean TypeScript interfaces or type aliases. Nested objects and mixed arrays are inferred automatically.

TypeScript output
✓ Types generated automatically in your browser

How to convert JSON to TypeScript

  1. Paste a representative JSON object or array.
  2. Choose a root name and interface or type alias output.
  3. Enable optional fields or date detection when appropriate.
  4. Copy the generated declarations into your TypeScript project.

How TypeScript inference handles real JSON

Mixed object arrays

Objects from the same array are merged into one shape. A property missing from some items becomes optional, while incompatible values produce a union type.

Nested declarations

Nested objects receive separate named declarations so parent types stay readable instead of containing deeply repeated inline structures.

Dates remain explicit

JSON has no date type. Enable date detection to annotate ISO-looking strings as Date, then remember that parsed JSON still contains strings until your application converts them.

Interfaces or aliases

Choose interfaces for extendable object declarations or type aliases to match a type-oriented codebase. The inferred property types are equivalent for ordinary object models.

Generated types do not validate runtime data

The result describes the supplied sample; it does not prove that future API responses have the same shape. Include multiple representative array items, null values, and fields that may be absent. Review names and unions, then use a runtime schema library when untrusted data must be validated before use.

Frequently asked questions

How are TypeScript types inferred from JSON?

Strings, numbers, booleans, null values, arrays, and nested objects are inspected recursively. Objects in the same array are merged, and fields missing from some items become optional.

Should I generate interfaces or type aliases?

Interfaces work well for object-shaped application models and can be extended or declaration-merged. Type aliases are useful when your codebase consistently prefers type syntax. For generated object models, either option is valid.

Is my JSON sent to a server?

No. JSON parsing and TypeScript generation run entirely in your browser.

Related tools