The Locolory toolkit / Developer Toolkit

JSON to TypeScript & Zod Schema Converter

Convert raw JSON payloads into TypeScript interfaces, type aliases, and runtime Zod validation schemas using private in-browser parsing and inference.

How do you generate TypeScript interfaces from JSON? Parse the JSON recursively, infer primitive and array element types, identify nested object shapes, and emit valid TypeScript declarations or Zod schemas.

  • Key formula: Observed JSON values map to TypeScript or Zod primitives; nested objects become named declarations or z.object schemas, and heterogeneous array elements become observed unions.

No Locolory server upload or conversion API call. Remove secrets and personal data before pasting; device, clipboard, extension, and screenshot risks still apply.

● Processed 100% locally in browser

JSON input + generated declarations

Raw JSON

Generated Types

export interface RootObject {
  id: number;
  name: string;
  email?: null;
  roles: Array<string>;
  profile: RootObjectProfile;
}

export interface RootObjectProfile {
  active: boolean;
  timezone: string;
}

Static Typing vs Runtime Validation: TypeScript vs Zod

TypeScript checks source code during development but its types are erased at runtime. External JSON can still violate an interface after the application is built.

Zod schemas inspect runtime values and can produce a TypeScript type with z.infer. Generated schemas are a starting point: review constraints, coercion, dates, formats, discriminators and API-version behavior.

JSON to TypeScript Type Mapping Rules

stringstring / z.string()
numbernumber / z.number()
booleanboolean / z.boolean()
nullnull / z.null()
arrayArray<T> / z.array(T)
mixed arrayobserved union
objectnested declaration / z.object
empty arrayunknown[] or any[]

Your input shapes the next update

Spotted something? Tell us.

A short note opens in your email app, ready to send to hello@locolory.store.

What would you like to share?
Have a screenshot? Attach or paste it in the email draft.0/3,000

Good questions. Clear answers.

Is it safe to paste confidential production API payloads into this tool?

Locolory does not upload the payload or call an API; conversion occurs in browser memory. Still remove API keys, credentials and personal data because the device, clipboard, extensions, screenshots or local monitoring may expose pasted content.

How does the converter handle arrays with mixed data types?

It creates a union of observed element types. For arrays made entirely of objects, it merges observed keys and marks keys missing from some elements as optional when the optional-fields setting is enabled.

Can I generate Zod schemas directly from nested JSON responses?

Yes. Nested objects, arrays, primitives, nulls and observed unions produce nested Zod declarations plus an inferred TypeScript type. Generated validation reflects only the supplied sample and should be reviewed against the API contract.

How are null and optional values represented in the output?

Null is inferred as the null type or z.null(). When optional fields are enabled, nullable fields and keys missing from some object-array elements also receive TypeScript ? or Zod .optional(). Null and missing remain distinct values in the underlying union/schema.