JSON KitJSON to TypeScript Interface

JSON to TypeScript Interface

Paste any JSON and instantly get TypeScript interfaces — ready to drop into your project.

Loading editor…
Loading editor…

Related Tools

What is JSON to TypeScript?

This tool converts a JSON sample into TypeScript interface declarations. Instead of manually writing types for every API response or LLM output, you paste the JSON and get ready-to-use TypeScript in seconds. It handles nested objects, arrays, nullable fields, and complex union types automatically.

The tool uses quicktype— the same engine behind VS Code's "Paste JSON as Code" feature — so the output is production-quality TypeScript, not a toy approximation.

How to Use This Tool

  1. Paste your JSON into the Input panel. The output updates automatically.
  2. Set the Root type name to something meaningful for your domain (e.g., User, ApiResponse).
  3. Toggle camelCase props if your JSON uses snake_case keys.
  4. Copy the output and paste it into your .ts or .d.ts file.
  5. For runtime validation, use the JSON to Zod Schema tool on the same input.

Example

Input JSON:

{
  "id": 1,
  "name": "Alice",
  "email": "alice@example.com",
  "role": "admin",
  "createdAt": "2024-01-15"
}

Generated TypeScript:

export interface Root {
    id:        number;
    name:      string;
    email:     string;
    role:      string;
    createdAt: string;
}

Frequently Asked Questions

What does this tool generate?
It generates TypeScript interfaces (or type aliases) from a sample JSON value. The output is ready to paste into your TypeScript project — no runtime dependencies needed. Nested objects become nested interfaces, arrays become typed arrays, and null values are represented as unions with null.
How does it handle arrays with mixed types?
When an array contains multiple different types (e.g., strings and numbers), the tool generates a union type like `(string | number)[]`. If arrays contain objects with different shapes, it will attempt to merge them into a single interface with optional fields where properties differ.
What's the difference between 'interfaces' and 'just types' mode?
'Just types' mode (default) outputs only the TypeScript type definitions — interfaces, type aliases, and enums. When disabled, quicktype also generates helper functions for parsing and validating at runtime. For most use cases, just types is what you want.
How do I handle null and undefined fields?
Fields that are null in the JSON sample are typed as `Type | null`. If you want optional fields instead (`field?: Type`), you can manually edit the output or add more sample data that shows the field populated. Always use real representative samples — a field that's sometimes missing should appear as null at least once in your samples.
What is 'nice property names'?
When enabled, snake_case keys like `created_at` are converted to camelCase `createdAt` in the generated interface, matching TypeScript naming conventions. The output includes a mapping so you know the original JSON key name.
Can I convert multiple JSON samples at once?
The tool infers types from a single sample. For better type inference — especially for optional fields — it helps to include the most complete JSON object you expect. If a field might be null or missing, include a version with it populated and one with it null.
How do I use the generated TypeScript in my project?
Paste the interfaces into a `.ts` file, then import and use them as type annotations: `const data: Root = await response.json()`. For runtime validation, pair this with the JSON to Zod Schema tool — it generates validators that match the TypeScript types.
Does this work with JSON arrays at the root level?
Yes. If your JSON is a top-level array (e.g., `[{"id": 1}, {"id": 2}]`), the tool generates an interface for the array item type and exports a type alias for the root as `RootElement[]` (or your chosen name + `[]`).

About This Tool

JSON to TypeScript is one of the most-searched developer tools in the TypeScript ecosystem. JSON Kit's implementation runs 100% in your browser using the quicktype-corelibrary — the same engine used in VS Code's official Paste JSON as Code extension. No data is sent to any server. Supports arbitrarily nested JSON, arrays of objects, nullable fields, and root-level arrays.