UnQTools
AI Runs in your browser

AI TypeScript Interface Generator

Generate TypeScript interfaces from JSON samples. Pure-JS recursive type inference — nested objects extracted into separate interfaces, optional & nullable handling, union types, enum (string-literal) detection, multi-sample merging for accurate optional fields, runtime type guards, and JSDoc from keys. Configurable root name, interface vs type, export, readonly, optional style, and array style. Optional BYO-key LLM. 100% client-side, nothing uploaded.

100% Private Works Offline Instant

About AI TypeScript Interface Generator

Generate TypeScript interfaces from JSON samples. Pure-JS recursive type inference — nested objects extracted into separate interfaces, optional & nullable handling, union types, enum (string-literal) detection, multi-sample merging for accurate optional fields, runtime type guards, and JSDoc from keys. Configurable root name, interface vs type, export, readonly, optional style, and array style. Optional BYO-key LLM. 100% client-side, nothing uploaded. Everything runs locally in your browser — your data never leaves your device.

How to use

  1. Enter your input in the tool above.
  2. Adjust any options to your preference.
  3. Use the Copy or Download buttons to save the result.
  4. Everything happens locally — your data never leaves your browser.

FAQ

How does the interface generator work?

Paste a JSON sample (a single object, an array, or an array of multiple samples) and the engine recursively infers the type of each value, extracts nested objects into their own interfaces, and emits clean TypeScript declarations. Strings, numbers, booleans, null, arrays, and nested objects are all handled. Optional fields are detected when you provide multiple samples and a key is missing in some of them.

How are optional, nullable, and union types handled?

Nullable fields (where 'null' appears alongside another type) become optional with the '?' modifier (or '| undefined' if you prefer). When a field has different types across samples — say string in one and number in another — the engine emits a union type like 'string | number'. Mixed-type arrays also produce union element types, with a warning suggesting you add more samples for accurate optionals.

Can I generate runtime validators and enums?

Yes. Toggle 'validators' to emit a TypeScript type-guard function (is<Name>) for each interface — these check the shape at runtime and narrow the type via 'v is <Name>'. Toggle 'enum inference' to detect small string-or-number literal sets in arrays and emit string-literal unions (e.g. "open" | "closed" | "pending") instead of plain string types.

What extra features does this tool have compared to others?

(1) Recursive nested-object extraction into separate interfaces. (2) Multi-sample merging for accurate optional-field detection. (3) Optional + nullable handling with two styles (? vs | undefined). (4) Union types for mixed-type fields. (5) String-literal and number-literal enum inference. (6) Runtime type-guard (validator) generation. (7) JSDoc comments from key names. (8) Interface vs type toggle. (9) Readonly toggle. (10) Export toggle. (11) Bracket vs generic array style (T[] vs Array<T>). (12) Empty-array handling with 'unknown[]' + warning. (13) Mixed top-level warning. (14) Root-name + key-path-based interface naming with singularization. (15) Reserved-word and invalid-identifier handling (quotes and suffixes). (16) Copy + Download .ts. (17) History (localStorage, last 20). (18) Shareable URL. (19) Sample presets. (20) Optional BYO-key LLM enhancement.

Is my JSON sent anywhere?

No. All JSON parsing, type inference, and TypeScript generation runs locally in your browser. Your data never leaves this device. The only network call is if you paste your own LLM API key and click 'Enhance' — that request goes directly from your browser to the LLM provider you choose. Types reflect only the sample(s) you paste; add multiple responses for accurate optionals. Nothing uploaded or logged by us.

Search tools and actions

Search across all 458 tools, categories, and quick actions.