The JSON to TypeScript converter reads a sample JSON value — an API response, a config file, a database record — and writes the TypeScript interfaces that describe it. Nested objects become their own named interfaces, arrays of objects are merged into a single element interface rather than a sprawling union, and keys that are null or missing from some records are marked optional. You paste data you already have; you get types you would otherwise hand-write.
Typing an API response by hand is tedious and error-prone in a specific way: you type what you *think* the endpoint returns, not what it actually returned. Fields you never noticed get omitted, an integer that is sometimes null gets typed as `number`, and the mistake surfaces at runtime in production rather than in your editor. Generating types straight from a real payload closes that gap, because the shape you compile against is the shape the server actually sent.
Everything runs in your browser. The inference engine is dependency-free TypeScript, not a wrapper around a remote service, so payloads — which routinely carry access tokens, customer records and internal IDs — never leave the page. Choose interfaces or type aliases, toggle the `export` keyword and `readonly` modifiers, pick your indent width, then copy the output or download a .ts file.
Drop in an API response, a fixture file or any JSON value. Load the sample first if you want to see how nested objects, arrays and null fields are handled.
Set the root type name — usually the resource, like User or Invoice. Nested interfaces are named automatically from their key, with array element names singularised (releases becomes Release).
Choose interface or type alias, decide whether to export each declaration, add readonly modifiers if your codebase prefers immutable shapes, and set the indent to 2 or 4 spaces.
Press Generate. Review the inferred optionals and unions, then copy the code to your clipboard or download it as a .ts file ready to drop into your types folder.
Every nested object becomes its own named, reusable interface instead of an inline anonymous shape, so you can import and reference the inner types independently.
An array of objects is merged into one element interface. Keys present in some records but not others become optional, which is exactly how real paginated API data behaves.
Choose whether a null value means the key is optional or whether null belongs in the union. Both conventions are common; the tool does not force one on your codebase.
Emit `interface User {}` or `type User = {}` to match your existing lint rules, with optional `export` and `readonly` modifiers applied consistently across every declaration.
Format, validate, and minify JSON data
Convert JSON to clean, valid YAML instantly — configurable indentation and safe string quoting
Convert JSON to well-formed XML instantly. Map object keys to elements, @-prefixed keys to attributes and #text to content, expand arrays into repeated tags, and export minified or pretty-printed XML. 100% client-side.
0 comments
No comments yet. Be the first to share your thoughts!