Free Developer Tool

JSON to TypeScript Converter

Turn sample JSON into readable TypeScript interfaces or type aliases, infer nested objects and arrays, and export a ready-to-edit .ts file privately in your browser.

Type Generation Workspace

Validation and inferred TypeScript update locally while you edit.

Pasted JSON475 / 750,000 characters
Declaration style

Valid JSON

Generated output is ready to review, copy, or download.

Inference notes

  • • Null values are emitted as null because one sample cannot reveal a wider intended type.

Declarations

3

Interfaces or aliases

Properties

15

Generated fields

Objects

4

JSON objects sampled

Arrays

1

JSON arrays sampled

Max depth

3

Nested data levels

Output lines

23

Generated TypeScript

Generated TypeScript

23 lines generated from the current sample.

Private browser generation

Parsing, inference, copying, and file creation happen locally without an upload.

Transparent inference

Missing array fields become optional, while empty arrays and ambiguous values stay safe.

Sample JSON is ready to convert.

How to Convert JSON to TypeScript

Paste a representative JSON response or open a local .json file. Give the root declaration a useful domain name, choose interfaces or type aliases, and review the inferred nested types. Copy the result into your project or download it as a TypeScript file.

  1. 1. Add sample JSON

    Use a realistic API response with the fields and array variations your application expects.

  2. 2. Choose output options

    Set the root name, declaration style, exports, readonly fields, optional fields, and date behavior.

  3. 3. Review and export

    Check ambiguous types against the API contract, then copy the declarations or download a .ts file.

How Type Inference Works

JSON strings, numbers, booleans, and null values map to matching TypeScript types. Nested objects receive named declarations based on their property names. Arrays use the types found in their sample items; mixed primitive arrays become unions, and object samples are combined into a shared item shape.

JSON sampleGenerated TypeScriptReview note
"active": trueactive: booleanDirect primitive match
"items": [{…}]items: Item[]Objects merge into an item declaration
"values": []values: unknown[]Empty arrays reveal no item type
"note": nullnote: nullRevise when the intended nullable type is known
Field absent in some array objectsfield?: TypeMissing sample fields become optional

Interfaces, Type Aliases, and Readonly Fields

Interfaces are a familiar choice for object contracts and can participate in declaration merging. Type aliases are equally valid for most generated object shapes and may fit projects that use aliases consistently. The readonly option prevents property reassignment during type checking; it does not freeze runtime JavaScript objects.

Why Generated Types Still Need Review

A sample describes observed values, not the complete API contract. It cannot reveal fields that never appear, every allowed string literal, future response variants, numeric constraints, or whether null represents a wider nullable type. Use generated declarations as a strong starting point, then compare them with official API documentation, schema files, tests, and real responses.

JSON has no native date value. ISO-looking strings stay strings unless date inference is enabled. Choose Date only if application code converts the serialized value before the typed object is used.

TypeScript and JSON References

Learn more from the official TypeScript documentation for object types and interfaces and type aliases. JSON syntax and interoperability are defined by RFC 8259. External references open in a new tab.

Private, Browser-Based Type Generation

JSON parsing, inference, copying, and TypeScript file creation run locally in your browser. Opened files do not need to be uploaded to generate the result. Refreshing the page clears the current workspace.

Continue Your Developer Workflow

Validate and clean the source with the JSON Formatter & Validator, convert configuration data using the YAML ↔ JSON Converter, transform spreadsheet exports with the CSV ↔ JSON Converter, or inspect API tokens in the JWT Decoder & Debugger.

For the wider request-and-response context, read What Is an API?.

JSON to TypeScript Converter FAQs