JSON → TypeScript
Genera interfacce
Informazioni su questo strumento
Paste any JSON sample and get strongly-typed TypeScript interfaces or types. Privvert detects optional fields by merging arrays of objects with different shapes, names nested types from their parent key, and quotes keys that aren't valid identifiers.
Useful for typing API responses, generating types from a config schema example, or kick-starting strongly-typed code from data you already have. Runs in your browser.
Funzionalità
- interface or type alias output
- Merges array element shapes into one type with optionals
- Names nested types from their parent key
- Quoted keys for non-identifier names
- Detects literal types where possible (booleans, common literals)
- Browser-only - JSON never uploaded
- Free and unlimited
- Optional readonly modifier on every property
Come si usa
- Paste a JSON example.
- Set the root type name.
- Pick interface or type output.
- Copy the generated TypeScript.
Tutto avviene all'interno del tuo browser con JavaScript e WebAssembly. I tuoi file non vengono mai caricati su un server, mai memorizzati e mai visti da noi.
Domande frequenti
Currently it produces 'string'. Literal-union inference (e.g. 'red' | 'green' | 'blue' from samples) is on the roadmap.
When you provide an array of objects, the tool merges all element shapes. Fields that are missing from any element become optional (?: T).
TypeScript types only, not enums. Use a literal union (one type alias with | between values) - that's the modern TypeScript-recommended approach over enums.
The tool generates a separate named type for each nested object. Names come from the parent key (e.g. user.address → Address).
Yes - it generates union types when the array contains different shapes. For arrays of objects with optional fields, the resulting interface marks the missing fields as optional automatically.
Yes. Type the name you want at the top of the input - the output will use it as the root interface. Nested types get sensible names derived from the parent property name.