JSON to Types Generator

Generate TypeScript, Zod, Go, Rust, Python, and 6 more languages from a JSON sample.

published

  • [FREE]
  • [NO_SIGNUP]
  • [NO_UPLOAD]

A JSON-to-TypeScript / Zod / Go / Rust / Python type generator infers strong types from a JSON sample and emits clean code in the target language of your choice. This tool runs entirely in your browser via quicktype-core, so the JSON you paste never touches a server.

How to use the JSON to types generator

  1. Paste a JSON sample. The most permissive sample you have — one that includes every field you want represented. The shape inference uses your sample as the only source of truth.
  2. Pick a target language. TypeScript and Zod cover most JS/TS projects. Go and Rust are the most common backend targets. Python, C#, Java, Kotlin, Swift, Ruby round out the rest. JSON Schema is useful for contracts shared across languages.
  3. Set the top-level name. Defaults to Root. Change to something semantic — User, ApiResponse, KubernetesManifest — and every nested object is named by its parent key.
  4. Copy, download, or share. Output is plain text, copy-paste-friendly. The share-by-URL hash round-trips the input + target + name so you can hand a link to a teammate.

What each target looks like

TypeScript

export interface User {
    id:     number;
    name:   string;
    active: boolean;
}

// Plus Convert helpers that validate at JSON.parse time
export class Convert {
    public static toUser(json: string): User { /* ... */ }
}

Zod (TypeScript)

import * as z from "zod";

export const UserSchema = z.object({
    "id": z.number(),
    "name": z.string(),
    "active": z.boolean(),
});
export type User = z.infer<typeof UserSchema>;

Go

type User struct {
    ID     int64  `json:"id"`
    Name   string `json:"name"`
    Active bool   `json:"active"`
}

func UnmarshalUser(data []byte) (User, error) { /* ... */ }

Rust

#[derive(Serialize, Deserialize)]
pub struct User {
    pub id: i64,
    pub name: String,
    pub active: bool,
}

Python

@dataclass
class User:
    id: int
    name: str
    active: bool

JSON Schema

{
    "$schema": "http://json-schema.org/draft-06/schema#",
    "$ref": "#/definitions/User",
    "definitions": {
        "User": {
            "type": "object",
            "properties": {
                "id":     { "type": "integer" },
                "name":   { "type": "string" },
                "active": { "type": "boolean" }
            }
        }
    }
}

Why generate types from JSON?

Hand-writing types for a third-party API or a legacy fixture is the kind of work that looks easy until you realize the API returns 47 fields, half of them nested, and you mis-typed one yesterday and shipped a bug. Generating from a sample takes 2 seconds and is right by definition — the type matches the data you actually have.

Common workflows:

  • Onboarding a new API client. Hit the endpoint with curl, paste the response, get a typed wrapper.
  • Round-tripping fixtures. Test data lives in JSON, but your code wants types. Regenerate when the fixture changes.
  • Validating untrusted input. Zod schemas paired with runtime parsing catch malformed data at the boundary.
  • Sharing contracts across languages. Generate JSON Schema, then derive from it in any language that has a code-gen tool (or use this site for the common targets).

Inference notes

  • Optional fields: a single sample says nothing about optionality — every field present is required. For full optional detection, the quicktype CLI accepts multiple --src arguments. The web UI ships single-sample-at-a-time.
  • Nullable: if a value is literally null in your sample, the type becomes T | null (or Option<T> / Optional per target).
  • Mixed-type arrays: [1, "two", true] becomes a union (number | string | boolean). Tuples are not inferred — if your array is fixed-shape, model it after generation.
  • Date strings: inferred as string. Some targets (TypeScript Convert, C# System.Text.Json) parse ISO timestamps to native date types automatically; others leave it as string.

Tooling note: lazy bundle

The quicktype-core library is ~250 KB gzipped. It downloads only when you click Generate the first time, so the initial page paint is fast. After the first generation it stays in memory and subsequent generations are instant.

Per-language landing pages (pre-filled examples)

Each link opens the generator with a sample JSON and the target language already selected:

How it compares

bytefork.toolsquicktype.iotransform.tools
Runs in browser
10+ target languages
Zod schema outputpartial
Share-by-URL hash (no account)requires VS Code extension for save
Ad-free
Bundle lazy-loadedupfrontupfront

Privacy and security

A static HTML page with a small JavaScript bundle. The quicktype-core library, once loaded, runs entirely in your browser tab. Your JSON never leaves the page. The share link encodes state in the URL fragment (#…) — that part of a URL is not sent to servers.

Frequently asked questions

Is my JSON sent to a server?

No. Generation runs in your browser via the quicktype-core library. The library is lazy-loaded on your first generation (~250 KB gzip). Open DevTools → Network and you will see no outbound request with your input. The share link encodes state into the URL hash (#…), which the browser does not transmit to servers.

Which target languages are supported?

TypeScript (interfaces with Convert helpers), Zod (z.object schemas with z.infer types), Go (structs with json tags + Unmarshal helpers), Rust (serde derives), Python (dataclass-style with type hints), C# (System.Text.Json POCOs), Java (POJO), Kotlin (data classes + kotlinx.serialization), Swift (Codable), Ruby (dry-struct), and JSON Schema (draft-06).

How does the tool know which fields are optional?

Type inference is structural. From a single sample, every field is treated as required because every field appeared. To mark fields as optional, paste multiple samples — the inferred type unions across the variation. The CLI version of quicktype accepts multiple --src arguments; the web UI infers from one paste at a time, so for full optional/nullable detection, prefer the CLI or paste the most-permissive sample.

Why does my array of mixed types generate a union?

Because that is what the data says. `[1, "two", true]` generates `(number | string | boolean)[]` in TypeScript. If you actually have a fixed-shape tuple, model it explicitly in your code after generation.

Do nested objects get their own types?

Yes. Every nested object becomes a named type, and the top-level type references it. The names are inferred from JSON keys, with smart casing (camelCase, PascalCase, snake_case depending on target convention).

Why is the TypeScript output so long?

By default, the TypeScript target emits both interfaces and runtime Convert helpers that validate JSON at parse time. If you only want the interfaces, the standalone quicktype CLI has a `--just-types` flag — this web UI ships the helpers because they are useful for safer JSON.parse usage. Delete the helper section after copying if you do not need it.

How big is the quicktype-core bundle?

About 250 KB gzipped. It only loads when you click Generate (lazy import), so the page itself paints fast. Subsequent generations are instant — the library stays in memory for the session.

Can I generate types from a JSON Schema instead of a JSON sample?

Not in this UI yet. quicktype-core supports it; for now this tool accepts JSON data only. Going JSON-Schema → target language is on the roadmap.

Does the generator handle dates?

It infers `string` for ISO 8601 timestamps, because JSON has no native date type. Some targets (TypeScript Convert helpers, C# with System.Text.Json) parse ISO strings to `Date` / `DateTime` automatically; others leave it as a string for you to parse.

Is this JSON-to-types tool really free?

Yes. No signup, no account, no ads, no telemetry on your input. The source is on the project repository.