JSON2Type
JSON2Type is a VS Code extension that converts JSON objects into TypeScript type definitions. Simply select any JSON text in your editor and convert it to properly formatted TypeScript types with syntax highlighting.
✨ Features
- 🔄 JSON to TypeScript Conversion: Convert any JSON object to TypeScript type definitions
- 🎨 Syntax Highlighting: Generated types are displayed with proper TypeScript syntax highlighting
- 📋 Copy to Clipboard: One-click copying of generated types
- 🌓 Theme Support: Automatic light/dark theme detection
- 🔧 Smart Type Extraction: Nested objects are extracted into separate type definitions
- ⚡ Context Menu Integration: Right-click any selected JSON to convert
🚀 Usage
- Select any JSON text in your editor
- Right-click to open the context menu
- Click "Convert JSON to Type"
- View the generated TypeScript types in a new panel
- Click "Copy to Clipboard" to copy the types

Method 2: Command Palette
- Select JSON text in your editor
- Open Command Palette (
Ctrl+Shift+P
/ Cmd+Shift+P
)
- Search for "Convert JSON to Type"
- Press Enter to generate types
📖 Example
Input JSON:
{
"user": {
"id": 123,
"name": "John Doe",
"email": "john@example.com"
},
"posts": [
{
"title": "Hello World",
"published": true,
"tags": ["typescript", "vscode"]
}
]
}
Generated TypeScript:
type userType = {
id: number;
name: string;
email: string;
};
type postType = {
title: string;
published: boolean;
tags: string[];
};
type rootType = {
user: userType;
posts: postType[];
};
⚙️ Configuration
The extension works out of the box with sensible defaults:
- Root Type Name:
rootType
- Singularization: Enabled (e.g.,
posts
→ postType
)
- Object Extraction: Enabled (nested objects become separate types)
- Indentation: 2 spaces
- Quotes: Single quotes
🎯 Requirements
- Visual Studio Code version 1.105.0 or higher
- No additional dependencies required
🐛 Known Issues
- Very large JSON objects may take a moment to process
- Complex nested structures might need manual type refinement
📝 Release Notes
0.0.1 - Initial Release
- ✅ Basic JSON to TypeScript conversion
- ✅ Context menu integration
- ✅ Syntax-highlighted output
- ✅ Copy to clipboard functionality
- ✅ Light/dark theme support
- ✅ Smart object type extraction
🤝 Contributing
Found a bug or have a feature request? Please open an issue on our GitHub repository.
📄 License
This extension is licensed under the MIT License.
Enjoy converting JSON to TypeScript! 🎉