snaptxt.app

JSON to TypeScript

Paste JSON and get TypeScript interfaces or type aliases instantly. Nested objects, arrays, and optional fields are handled — all in your browser.

Valid JSON
JSON
TypeScript

How to use it

  1. 1Paste a JSON object or array on the left.
  2. 2Set a root type name and choose interface or type alias output.
  3. 3Copy the generated TypeScript from the right.

Common use cases

  • Type an API response you just got back from a fetch call.
  • Bootstrap types from a sample payload instead of writing them by hand.
  • Keep front-end types in sync with a backend's JSON shape.
  • Turn a config file into a typed structure for safer code.

Frequently asked questions

Does it handle nested objects and arrays?
Yes. Nested objects become their own named types, and arrays are typed by their element shape.
How are optional fields detected?
When an array contains objects with differing keys, keys missing from some elements are marked optional with `?`.
Interface or type alias?
Both — toggle between `interface` and `type` output. Interfaces are common for object shapes; type aliases are handy for unions and composition.
Is my JSON uploaded?
No. Conversion happens entirely in your browser — your data never leaves your device.