Xepoca
← Back to Xepoca

Developer tool

JSON to TypeScript Converter

Turn JSON samples into clean TypeScript interfaces or type aliases. Infer nested objects, arrays, unions, optional properties, reusable shapes, and date values without sending your data anywhere.

🔒 100% private browser processing

Your JSON never leaves your device. Xepoca parses the input, infers types, and builds the TypeScript output entirely in your browser.

JSON input

Paste a JSON value or load a local JSON file.

Pasted JSON477 B

TypeScript preview

Generated declarations are ready to copy into a `.ts` file.

Generate TypeScript to preview reusable declarations here.

How JSON becomes TypeScript

JSON contains runtime values, while TypeScript describes the shapes those values are expected to have. Xepoca inspects each JSON value and maps strings, numbers, booleans, nulls, arrays, and objects into TypeScript types.

Arrays of objects are especially useful samples. The converter merges object shapes across the array, combines differing value types into unions, and marks keys as optional when they are missing from some sampled objects.

Nested object shapes are emitted as reusable declarations instead of deeply inlining every object. Identical inferred shapes reuse the same declaration, which keeps generated TypeScript easier to read and maintain.

Useful generation controls

Interfaces or aliases

Generate interface declarations for object shapes or switch to object type aliases when that better matches your project style.

Optional-key inference

When array objects do not all contain the same key, inferred mode marks that property optional instead of pretending every sample has it.

Date detection

Keep ISO timestamps as strings by default, or opt into Date types when your application converts those strings into Date instances.

Safe property names

Keys such as app-name or 2fa-enabled are automatically quoted so the generated declaration remains valid TypeScript.

Related Xepoca tools

Frequently Asked Questions

Is the JSON to TypeScript Converter free?+

Yes. You can generate, copy, and download TypeScript without creating an account.

Is my JSON uploaded?+

No. JSON parsing and type inference happen locally in your browser, so the source data stays on your device.

How are optional properties inferred?+

For arrays of objects, a property is optional when it is missing from one or more sampled objects. You can override this and make every property required or optional.

What happens with empty arrays?+

An empty array does not contain enough information to infer its element type, so Xepoca generates unknown[] and shows an inference note for you to review.

Does a generated Date mean JSON contained a Date object?+

No. JSON only contains strings. Date detection is optional and maps ISO-style timestamp strings to Date because your application may deserialize them into Date instances.

Can generated types replace API schemas?+

Generated TypeScript is a useful starting point based on the sample you provide. Review it against the full API contract because a single sample may not reveal every possible field or value type.