Mixed Types & Union Types – JSON to Typedef Example
See how the converter handles mixed-type arrays and fields with different value types, producing union types in TypeScript and object fallback in C#.
What this demonstrates: This example features: mixed-type arrays (tags with numbers, strings, booleans, and null), objects with different shapes in the same array (events with different metadata structures), null values creating optional types, and nested configuration objects.
Paste JSON on the left to generate typedefs
Supports Nested Objects and Arrays
Our converter recursively processes deeply nested JSON structures, including arrays of objects, mixed-type arrays, and multi-level object hierarchies. Each nested object gets its own named interface (TypeScript) or class (C#) with properly typed properties.
Optional Fields and Mixed Types Handled
When a field is null in your JSON, it's automatically marked as optional in TypeScript (with ?) or nullable in C#. Arrays with mixed element types produce union types or fallback to object.
How to Use This JSON to Typedef Converter
Paste JSON
Paste or type your JSON into the input area on the left.
Choose Language
Select TypeScript or C# from the dropdown.
Copy Output
Your type definitions appear instantly. Click Copy to use them.