Effortlessly generate TypeScript types from JSON data in Visual Studio Code with a single command.
- Automatically generate TypeScript types from JSON files
- Supports complex and nested JSON structures
- Generates union types for arrays with different element types
- Works with both the Command Palette and the File Explorer context menu
There are two ways to use the JSON to TypeScript Types Generator extension:
-
Command Palette: Open a JSON file or paste JSON content in an editor, then press
Ctrl+Shift+P
(orCmd+Shift+P
on macOS) and search for "Generate TypeScript Types" to run the command. The extension will generate TypeScript types and display them in a new file with a.types.ts
extension. -
File Explorer context menu: Right-click on a JSON file in the File Explorer, then select "Generate TypeScript Types" from the context menu. The extension will generate TypeScript types and display them in a new file with a
.types.ts
extension.
- Open Visual Studio Code.
- Press
Ctrl+P
(orCmd+P
on macOS) to open the Quick Open dialog. - Type
ext install mzbac.json2type
and press Enter to install the extension.
If you'd like to contribute to the development of this extension, feel free to open an issue or submit a pull request on the GitHub repository.
This extension is released under the MIT License.