Converter Tool

JSON to Types Converter

Paste a payload and get TypeScript, Zod, or Go types you can drop into a repo. Inference stays local.

TypeScript + Zod + GoNamed nested types100% Client-Side

Generate types from a real API payload

Paste a response, name the root type, and copy TypeScript, Zod, or Go. Nested objects become named types so you do not get one giant inline blob.

This is the honest home for “JSON to TypeScript”. The JSON formatter does not export types.

TypeScript, Zod, and Go output

From the sample user object you get something like:

export interface Address {
  "city": string;
  "postcode": string;
}

export interface User {
  "id": string;
  "email": string;
  "plan": string;
  "address": Address;
  "roles": string[];
  "lastLogin"?: null;
}

Zod emits z.object plus z.infer. Go emits structs with json tags. Switch interface off if you want TypeScript type aliases.

What inference cannot know

  • Empty arrays: pick unknown[] or any[].
  • null today might be a string tomorrow.
  • Mixed arrays collapse to a union or to any in Go.
  • Numbers that are IDs stay number / float64. They are not branded IDs.

When to use a schema instead

If the next payload must fail when a field is missing, write or generate a schema in the JSON Schema Validator. Types are for the compiler. Schemas are for the wire.

Pretty-print first with the JSON Formatter & Validator if the paste is minified.

How to use

  1. Paste JSON and set the root name.
  2. Choose TypeScript, Zod, or Go.
  3. Copy or download .ts / .go.

Privacy

The payload never leaves the browser.

Frequently Asked Questions

Are the generated types guaranteed for the next payload?

No. They are inferred from the sample you pasted. An empty array, a null field, or a mixed-type array will be guessed. Use a JSON Schema when you need a contract.

How are nested objects named?

Nested objects become named types from their key, with a unique suffix if the name collides. The root name field sets the top type.

What do null fields become?

A null value is treated as optional. In Go it becomes a pointer with omitempty. That is a guess, not proof the field is always omitted.

Does this validate JSON Schema?

No. That is the JSON Schema Validator. This page only infers types.

Is the payload uploaded?

No. Generation runs in the browser.