Convert JSON to TypeScript interfaces, Python dataclasses, Go structs, Rust structs, or Zod schemas. Select JSON, pick a language, get types instantly.
Features
5 Output Languages
- TypeScript -
export interfacewith proper types - Python -
@dataclasswith type hints - Go -
structwith JSON tags - Rust -
structwithserdederive macros - Zod - Schema with
z.infertype extraction
Smart Type Inference
- Detects
string,number,boolean,nullautomatically - Distinguishes integers from floats
- Handles nested objects as separate named types
- Processes arrays with element type inference
Multiple Workflows
- Select JSON in editor and run the command (Ctrl+Shift+J)
- Right-click context menu on selected JSON
- Convert from clipboard - paste JSON from any source
Nested Object Support
Complex nested JSON produces multiple separate types, each properly named from the key.
Example
Input JSON:
{
"id": 1,
"name": "Alice",
"email": "[email protected]",
"address": {
"street": "123 Main St",
"city": "Springfield"
},
"tags": ["admin", "user"]
}
TypeScript Output:
export interface Address {
street: string;
city: string;
}
export interface Root {
id: number;
name: string;
email: string;
address: Address;
tags: string[];
}
Commands
| Command | Keybinding | Description |
|---|---|---|
| JSON to Types: Convert Selection | Ctrl+Shift+J | Convert selected JSON |
| JSON to Types: Convert from Clipboard | - | Convert JSON from clipboard |
Settings
| Setting | Default | Description |
|---|---|---|
jsonToTypes.defaultLanguage |
typescript |
Default output language |
jsonToTypes.rootName |
Root |
Name of the root type |
jsonToTypes.optionalFields |
false |
Mark all fields optional (TS) |
jsonToTypes.exportInterfaces |
true |
Add export keyword (TS) |
Use Cases
- API Development: Paste API response JSON, get typed interfaces instantly
- Database Modeling: Convert JSON documents to typed structs
- Code Generation: Rapid prototyping with type-safe models
- Learning: See how JSON maps to types in different languages
Installation
code --install-extension miccho27.json-to-types
Or search "JSON to Types" in the VS Code Extensions panel.
License
MIT