PlayWithJSON

JSON to TypeScript Converter

Interfaces & Types

Generate TypeScript interfaces or type aliases from any JSON or JSON5 payload instantly in your browser.

Samples:
Declare as:
Indent:
JSON / JSON5 InputJSON
19 lines | 409 charsJSON
TypeScript OutputTS
export interface Root {
  status: string;
  statusCode: number;
  data: Data;
  timestamp: string;
}

export interface Data {
  userId: string;
  username: string;
  email: string;
  profile: Profile;
  preferences: Preferences;
}

export interface Profile {
  firstName: string;
  lastName: string;
  skills: string[];
}

export interface Preferences {
  theme: string;
  notifications: boolean;
}
25 lines | 398 charsTS

JSON to TypeScript Converter Online

Paste any JSON or JSON5 and instantly get clean TypeScript interfaces or type aliases. Nested objects become named types, arrays are merged into a single element type, and fields missing from some array items are marked optional.

Everything runs inside your browser. Your payloads are never uploaded to a server, so API responses and configuration files stay private.

{}

Why Use PlayWithJSON?

  • Interfaces or type aliases with one click
  • Nested objects extracted into named types
  • Optional fields detected from array items
  • 100% client-side and offline capable
  • Supports JSON5 comments and unquoted keys

What Can You Do With Our JSON to TypeScript Converter?

Instant Type Generation

Types update live as you edit the JSON, with precise error lines for invalid input.

Interface or Type Alias

Switch between interface and type declarations to match your codebase style.

Smart Union & Optional Detection

Mixed arrays produce unions and missing keys become optional properties.

Custom Naming & Indentation

Choose the root type name, 2 or 4 space indentation, export and readonly modifiers.

JSON5 Input Support

Comments, trailing commas and unquoted keys are accepted in the input.

Copy or Download

Copy the generated code or download it as a ready-to-use .ts file.

How to Convert JSON to TypeScript Online

1

Paste Your JSON

Paste JSON or JSON5 into the left panel or load a sample.

2

Pick Your Options

Choose interface or type, the root name, indentation and modifiers.

3

Review the Types

The TypeScript output updates instantly on the right.

4

Copy or Download

Copy the result or download it as a .ts file.

JSON to TypeScript Example

JSON (Input)
{ "id": 1, "name": "Asha", "tags": ["admin", "beta"], "address": { "city": "Jaipur" } }
TypeScript (Generated)
1export interface Root {
2 id: number;
3 name: string;
4 tags: string[];
5 address: Address;
6}
7
8export interface Address {
9 city: string;
10}

Input Validation

Invalid Input
1{
2 "name": "PlayWithJSON"
3 "fast": true
4}
Syntax error: missing comma between properties
Valid Input
1{
2 "name": "PlayWithJSON",
3 "fast": true
4}

Supported Features

Interfaces and type aliases
Nested object extraction
Union types for mixed arrays
Optional property detection
Nullable fields
Readonly modifiers
Custom root type name
JSON5 input parsing
Copy and download as .ts
Works on mobile and desktop
100% private in-browser processing
Frequently Asked Questions

Frequently Asked Questions about JSON to TypeScript

Yes. Every nested object becomes its own named type, and arrays are typed from all of their elements, merging objects and producing unions when element types differ.

More JSON Developer Tools

View All Tools

JSON Formatter

Format, validate and inspect JSON data

JSON5 Formatter

Format and validate JSON5 with comments

JSON ↔ JSON5

Convert between JSON and modern JSON5

JSON to TypeScript

Generate TypeScript interfaces from JSON

JSON to Zod

Generate Zod schemas from JSON

Text to JSON

Convert text and schemas into structured JSON

JSON Sorter Online

Sort JSON keys alphabetically and order arrays

JWT Decoder Online

Decode JWT header, payload and expiration

JSON Stringify Online

Escape quotes and stringify or unescape JSON

Mock JSON Generator

Generate realistic mock data for APIs and testing

JSON to CSV

Export structured JSON arrays into CSV spreadsheets

JSONPath Tester

Query and filter JSON data with path expressions

JSON Schema Generator

Generate JSON Schema from sample JSON

JSON Diff & Compare

Compare two JSON objects and find differences

JSON ↔ YAML

Convert JSON/JSON5 to YAML and back with comments

JSON ↔ XML

Convert JSON to XML and XML to JSON with attributes

YAML to CSV

Convert YAML lists and objects into spreadsheets

CSV to JSON / JSON5

Convert CSV/TSV to JSON or JSON5 with type parsing

JSON to BigQuery

Generate BigQuery Schema JSON and CREATE TABLE DDL

JSON to GraphQL

Generate GraphQL SDL types, queries, and inputs

JSON to MySQL

Generate MySQL CREATE TABLE DDL and INSERT queries

JSON to PostgreSQL

Generate PostgreSQL CREATE TABLE DDL, JSONB and INSERTs

JSON Flattener

Flatten nested JSON to dot notation or unflatten back

JSON Tree Visualizer

Interactive SVG mindmap graph and collapsible node tree

JSON Minifier Online

Compact and compress JSON by stripping whitespace

JSON Token Counter

Calculate LLM tokens (GPT-4o, Claude) and API costs

Broken JSON Repair

Automatically heal broken and truncated AI/LLM JSON