For JSON to typescript work, the important part is whether the output is easy to verify. JSON to TypeScript puts interface up front, browser-side processing is useful for sensitive snippets, and it handles ts interface generator work without sending me to another page.
Type inference
- number / string / boolean → primitive types
- null →
null - Object → nested interface or type
- Homogeneous array →
T[] - Heterogeneous array → union
(A | B)[] - Empty array →
unknown[]
Tips
- Choose
interfacewhen you need declaration merging or extension - Choose
typealias for unions, mapped or conditional types readonlyfor immutable API responses- Mark fields optional (
?) when the API may omit them - Pipe into
npx prettierif you need stricter formatting