Convert JSON into TypeScript types instantly β inside VS Code. Handles messy json as well, repairs and then converts into typescript type.
No context switching. No online tools. Just select JSON and generate types in seconds.
- β‘ Convert JSON β TypeScript types instantly
- π― Works on selected JSON or entire file
- π§ Smart type inference (objects, arrays, primitives)
- βοΈ Editable type name (no more
Tpain) - π Cursor placed exactly where you need to edit
- π§© Seamless VS Code integration
Search for:
JSON to TypeScript Interfaces
git clone https://github.com/YOUR_USERNAME/json-to-typescript-interfaces.git
cd json-to-typescript-interfaces
npm installThen press:
F5
{
"name": "Aryan",
"age": 24,
"isActive": true
}
1. select the json
2. Ctrl + Shift + T
or
1. select the json
2. Ctrl + Shift + P
3. search for "Generate TypeScript from JSON" and hit enter
type T = {
name: string;
age: number;
isActive: boolean;
}π The type name is pre-selected β just start typing to rename.
- Parses selected JSON
- Infers TypeScript types
- Generates a clean type definition
- Inserts it directly into your editor with smart cursor positioning
{
"user": {
"id": 1,
"name": "John"
},
"tags": ["dev", "ts"]
}type T = {
user: { id: number; name: string; };
tags: string[];
}Real-world JSON is rarely perfect.
Logs, LLM outputs, and APIs often return invalid or sloppy JSON like:
{
a: lam,
c: "2",
d: 3,
}β This would normally crash JSON.parse
Before generating types, it automatically repairs malformed JSON using relax-json.
It intelligently fixes:
- Unquoted keys β
"a" - Single quotes β
"value" - Unquoted string values β
"lam" - Trailing commas
- Comments (
//and/* */)
{
a: lam,
c: "2",
d: 3,
}{
"a": "lam",
"c": "2",
"d": 3
}type T = {
a: string;
c: string;
d: number;
}Most tools fail on anything that isnβt perfectly valid JSON.
This extension:
- β Recovers broken JSON automatically
- β Works with real-world data (not just ideal inputs)
- β Saves time debugging tiny syntax issues
Repair is best-effort, not magic:
- Extremely broken structures may still fail
- Always review generated types for critical systems
- Mixed-type arrays are simplified (
(string | number)[]not yet supported) - No optional field detection yet
- Nested types are inlined (no separate interfaces)
- Optional field detection
- JSON schema support
Contributions are welcome!
git clone https://github.com/YOUR_USERNAME/json-to-typescript-interfaces.gitOpen an issue or submit a PR π
If you find this useful:
- β Star the repo
- π¦ Share with other devs
- π§ Suggest improvements
MIT
Because switching to random websites to convert JSON β TS breaks flow.
This extension keeps you in the zone.
Made with β€οΈ for developers