# JSON to TypeScript > Free JSON to TypeScript converter that runs in the browser: paste JSON or drop a .json or JSON Lines file and get TypeScript interfaces (or type aliases) plus a matching Zod schema, with optional and nullable fields worked out from every value. Nothing is uploaded. An optional, metered AI step suggests clearer type names, unions of named values, string formats and doc comments, and the page checks each suggestion against every value before applying it. URL: https://json-to-typescript.skillsafe.ai/ API: https://json-to-typescript.skillsafe.ai/api.html ## What the free converter does (in the browser, no sign-in) - Reads strict JSON; reads JSON Lines (one value per line) as a list; removes // and /* */ comments and trailing commas when strict reading fails, and says so; otherwise reports the line and column where the text stops being JSON and why (missing comma, unquoted name, single quotes, a comment, unclosed bracket). - Looks at every value at every path. Each object type is named from its key in PascalCase (items -> Item, categories -> Category, people -> Person; built-in names such as Date or Event get a suffix). Objects at different places with the same name and the same fields share one type; different fields under the same name get the parent's name as a prefix. - In a list of objects, a field missing in some items becomes optional (field?: T); a field that is sometimes null becomes T | null; mixed kinds become a union; a list that is always empty becomes unknown[]; a field that is always null becomes null and is listed so it can be set by hand. - Writes TypeScript interfaces or type aliases (export, readonly and T[] or Array are options) and a Zod schema (z.object, z.array, z.union, .optional(), .nullable(), .int() for whole numbers, and .uuid(), .datetime({ offset: true }), .date(), .email(), .url() when every value fits), with z.infer types, children before parents. Optional .strict() objects. - Flags whole numbers beyond 2^53 that JavaScript cannot hold exactly. - Download the .ts file of types or of Zod validators, or copy either. ## Optional AI step (sign-in, metered) Task id `refine`. Sends the generated TypeScript and a summary of each type and field (path, current type, how many objects have it, nullable, distinct count, detected format and, if the visitor allows, up to 5 example values). Never the JSON itself. The model returns JSON: `names` (type renames by path), `enums` (fixed sets of string values), `formats` (uuid, date-time, date, email, url), `docs` (one-sentence comments) and `notes`. The page applies a name only if no type with different fields has it, a set of values only if every value in the JSON is in it, a format only if every value fits, and lists what it refused and why. ## Sources Adapted from the agent skill @wshobson/typescript-advanced-types (MIT), https://skillsafe.ai/skill/@wshobson/typescript-advanced-types, from github.com/wshobson/agents.