πŸ”’ Runs in your browser β€” nothing is uploadedβœ“ Free, no signup

JSON to TypeScript Interface Generator

Paste JSON β€” like an API response β€” to generate TypeScript interfaces instantly. Nested objects, arrays, optional fields and unions are handled for you.

Loading...
Loading...

When should you use the JSON to TypeScript?

  • Typing an API response in a React, Next.js or Node.js project
  • Creating types for a config file or fixture data
  • Documenting the shape of a JSON payload for your team

How to use the JSON to TypeScript

  1. 1

    Paste JSON

    Paste an object or array into the left editor, or click Load sample.

  2. 2

    Name the root type

    Change Root to something meaningful, such as User or ApiResponse.

  3. 3

    Pick a style

    Choose interface or type, and whether to export the declarations.

  4. 4

    Copy into your project

    Use Copy Output and paste into a .ts file.

Examples

Array items with an optional field

JSON

{
  "orders": [
    { "id": 10, "total": 9.5 },
    { "id": 11, "total": 20, "coupon": "SAVE" }
  ]
}

TypeScript

export interface Root {
  orders: Order[];
}

export interface Order {
  id: number;
  total: number;
  coupon?: string;
}

Common errors and how to fix them

Invalid JSON
The input must be valid JSON. Use the JSON Validator to find the error, or the JSON Formatter's Fix JSON button to repair it.
A field should be optional but isn't
The generator only knows what's in your sample. Include an example item where the field is missing, or add ? by hand.
Related tools:Β JSON Formatter Β· JSON Schema Generator Β· CSV to JSON Converter

Explore More Developer Tools

Format, Validate, and Generate Data Instantly

TrueFormatter provides essential utilities for modern web development, including JSON formatting, YAML conversion, and more.

JSON Auto-Fixer & Formatter

Repair, validate, and beautify broken JSON (missing quotes, trailing commas).

JSON Validator & Linter

Check JSON syntax and see the exact line and column of every error.

JSON Beautifier

Pretty-print and indent JSON for easy reading and debugging.

JSON Compare & Diff Tool

Find the difference between two JSON objects visually and quickly.

JSONPath Tester

Evaluate JSONPath expressions with filters and recursive queries.

JSON Schema Generator

Generate a JSON Schema from any sample JSON document.

JSON to CSV Converter

Flatten nested JSON arrays into CSV for spreadsheets.

YAML ⇆ JSON Converter

Convert YAML to JSON or JSON to YAML instantly.

CSV to JSON Converter

Convert CSV or TSV data to a JSON array of objects, with type detection.

JSON to TypeScript

Generate TypeScript interfaces from any JSON sample.

JWT Decoder

Decode and inspect JSON Web Tokens (JWT) Header and Payload.

JWT Generator

Create and sign HS256/HS384/HS512 JSON Web Tokens for testing.

Hash Generator (MD5, SHA)

Generate MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes.

Password Generator

Generate strong, random passwords with the length and characters you choose.

Base64 Encoder ⇆ Decoder

Encode text to Base64 and decode Base64 to text for API debugging.

URL Encoder & Decoder

Cleanly encode special characters in URLs and decode query strings.

SQL Formatter & Beautifier

Format SQL queries for MySQL, PostgreSQL, SQL Server, SQLite and more.

CSS Minifier & Compressor

Optimize CSS by removing whitespace and comments to accelerate page load time.

JS Minifier & Compressor

Compress JavaScript to improve website speed and performance.

HTML Formatter & Beautifier

Beautify or minify HTML with clean, consistent indentation.

Markdown Editor & Preview

Write Markdown with a live preview and copy the HTML.

Word & Character Counter

Count words, characters, sentences and reading time as you type.

Case Converter

Convert text to camelCase, snake_case, kebab-case, Title Case and more.

Text Diff & Compare

Compare two texts and highlight every added and removed word or line.

Lorem Ipsum Generator

Generate placeholder paragraphs, sentences or words as text or HTML.

Fancy Text & Font Generator

Turn text into 𝐛𝐨π₯𝐝, π˜ͺ𝘡𝘒𝘭π˜ͺ𝘀, π“ˆπ’Έπ“‡π’Ύπ“…π“‰ and other Unicode font styles you can paste anywhere.

Color Picker & Converter

Pick a color and convert between HEX, RGB and HSL instantly.

Color Palette Generator

Generate harmonious color palettes and export them as CSS, Tailwind or JSON.

CSS Gradient Generator

Build linear and radial CSS gradients visually and copy the code.

PX to REM Converter

Convert pixels to rem and rem to pixels for any root font size.

Regex Tester & Debugger

Test JavaScript regular expressions with live match highlighting and groups.

Cron Expression Generator

Build cron schedules, read them in plain English and preview next runs.

UUID / GUID Generator

Generate unique V4 UUIDs for database keys or testing.

Epoch converter online

Convert UNIX timestamps to human-readable dates and back instantly.

Time Zone Converter

Convert a time between time zones and compare cities side by side.

Random Number Generator

Generate random numbers in any range β€” unique, sorted or decimals.

Crop Image Online

Crop images exactly as selected with fixed aspect ratios. No upload, no resize, no quality loss.

Compress Image Online

Compress JPG, PNG & WebP images directly in your browser. No upload, no tracking, instant download.

Image Resizer

Resize images to exact pixels or a percentage, keeping the aspect ratio.

Image Converter (PNG, JPG, WebP)

Convert images between PNG, JPG and WebP in your browser.

Image to Base64

Convert an image to a Base64 data URI for CSS, HTML or JSON.

JSON to TypeScript FAQ

Paste a JSON object or array β€” for example an API response β€” and TypeScript interfaces appear instantly. Nested objects become their own named interfaces.

All objects in the array are merged into one interface. If a key appears in only some items, it's marked optional with ?. If a key has different types across items, it becomes a union like string | null.

Both work for describing object shapes. Interfaces can be extended and merged, and are the common default; type aliases are needed for unions. Tick 'Use type instead of interface' if your codebase prefers type.

The generator can only see your sample. A field that's null everywhere becomes null, and an empty array becomes unknown[]. Paste a sample where those fields have real values, or edit the types afterwards.

Keys that aren't valid TypeScript identifiers are quoted, for example "zip-code": string.

No. Types are generated in your browser, so it's safe to paste real API responses.