Options:
JSON Input
TypeScript Interface
⚙️ How the JSON → TypeScript Converter Works
The converter uses a depth-first traversal algorithm to walk the JSON tree, inferring types for every value and creating nested interfaces where needed.
string → string
number → number
boolean → boolean
null → null / ? (optional)
array → Type[] (or Union[] if mixed)
object → Interface (recursive)
1
Parsing: The JSON is validated using the browser's native
JSON.parse(). If it fails, an error is caught and displayed.2
Type Inference: The
typeof operator evaluates primitive values. Arrays map through their elements to build a unique set of types (e.g., (string | number)[]).3
Recursive Objects: When an object is encountered, a new named interface is spun up. The parent interface references this new child interface by name (e.g.,
address: Address;).
Why Top-Down matters: The algorithm collects all nested interfaces in a Map, guaranteeing that dependencies are declared correctly before the root interface.
All logic runs entirely client-side. No data is sent to a server.