Free Tool

JSON to TypeScript Converter

Stop writing TypeScript types by hand. Paste a JSON API response and get ready-to-use interfaces in seconds — with nested types, unions, and optional fields.

Loading editor…

How to Use the JSON to TypeScript Converter

  1. 1

    Paste a JSON object or API response into the editor above.

  2. 2

    JSON Flash instantly generates TypeScript interfaces for every nested object.

  3. 3

    Set the root interface name in the settings panel (e.g., "ApiResponse" instead of "Root").

  4. 4

    Toggle between interface and type alias syntax to match your codebase style.

  5. 5

    Copy the generated TypeScript to your clipboard and paste it into your project.

Key Features

Recursive Interface Extraction

Every nested object becomes its own named interface, keeping your types modular and reusable across your codebase.

Union Types

Mixed-type arrays (string | number)[] and nullable fields (string | null) are detected automatically.

Optional Fields

Provide multiple JSON samples and JSON Flash detects which fields are sometimes absent, marking them as optional (field?: type).

Instant Output

The TypeScript output updates in real time as you edit the JSON — no submit button needed.

Why JSON Flash?

  • Generates separate named interfaces for every nested object — not one giant flat type.
  • Detects union types, null, and optional fields accurately.
  • Choose interface or type alias syntax to match your team style guide.
  • Pro: export Zod schemas alongside TypeScript interfaces.
  • Free with no limits for typical API response sizes.

Frequently Asked Questions

How do I generate TypeScript types from JSON?

Paste your JSON into the editor above and click Convert. JSON Flash analyses the structure and emits TypeScript interfaces for every nested object, with correct primitive types (string, number, boolean, null) and array types.

Does the converter generate interfaces or type aliases?

You can choose. The default output uses interface declarations (interface User { ... }), which are preferred by most TypeScript style guides. Toggle "Use type aliases" to produce type User = { ... } instead.

How are optional fields detected?

If you provide multiple JSON samples (Pro feature), JSON Flash compares them and marks any key that is absent from one or more samples as optional (field?: type). With a single sample, all fields are required by default, with an option to mark them all optional.

How are arrays of mixed types handled?

Arrays containing values of different types produce a union type (string | number | null)[]. Arrays of objects produce an array of the inferred interface type.

What root interface name is used?

The default root interface name is "Root". You can change it to any valid TypeScript identifier in the settings panel — for example, "ApiResponse" or "UserProfile".

Can the converter handle deeply nested JSON?

Yes. JSON Flash recursively traverses any depth of nesting and generates a separate named interface for each nested object, keeping the output clean and reusable.

Does it handle null values?

Yes. Null values produce a "type | null" union. If a field is both absent and null across samples, it becomes "type | null | undefined".

Can I use the generated types with Zod or other validators?

Pro users can export Zod schemas in addition to TypeScript interfaces — useful for runtime validation that mirrors compile-time types. Output includes z.infer<> type aliases for full type-safety.

Unlock Pro — unlimited AI, 10 MB files, API access

Starting at $4/mo · 14-day money-back guarantee

  • Optional field detection from multiple JSON samples
  • Zod schema export alongside TypeScript interfaces
  • Readonly and Partial utility type wrappers
  • JSDoc comment generation from key names
  • API endpoint for CI/CD pipeline integration
Upgrade →