Skip to content
Web Codes Stack
Explore Free Tools

JSON to TypeScript Converter

Generate editable TypeScript definitions from a JSON sample, including nested objects and arrays.

How to use it

  1. Paste a representative JSON sample and enter a root type name if you have one.
  2. Select Generate TypeScript and review the generated definitions, focusing on nullable fields, arrays and properties that may be missing in real data.
  3. Copy the TypeScript or download the .ts file, then adapt the types to your API contract.

Practical example

Type a list returned by an API

{
  "users": [{"display-name": "Ada", "workspaceId": 42}],
  "nextPage": null
}

Use UsersResponse as the root name. The output quotes the hyphenated property and reflects the observed null. Widen nextPage if the API can also return a string or number.

Frequently asked questions

Will the generated definitions validate a network response?

TypeScript checks types during development. Use a separate runtime validator when a response comes from an untrusted or changing source.

How are property names with spaces or hyphens handled?

Names that cannot safely be emitted as identifiers are represented as quoted property names.

What happens with mixed arrays?

The generator represents the observed element types as a union. Empty arrays use Array<unknown> until you can supply a representative element type.

Related tools

JSON Schema Generator

Generate a starter Draft 2020-12 schema from a sample JSON document.

Open tool

JSON Formatter

Pretty-print or minify JSON with two-space or four-space indentation.

Open tool

JSON Validator

Check JSON syntax and locate parsing errors with clear feedback.

Open tool