Convert JSON to TypeScript interfaces effortlessly.
An open-source tool for developers to generate TypeScript types from JSON objects quickly and securely.
- Fast Conversion: Generate TypeScript interfaces from JSON in seconds.
- Nested Objects Support: Handles deeply nested structures with ease.
- Secure Offline Use: No need to paste your data online—works locally.
- Customizable: Future support for advanced type handling and customizations.
Install the package via NPM:
npm install -g @typeweaver/json2ts
Convert a JSON file to a TypeScript interface:
json2ts convert input.json output.ts
Or use JSON from the clipboard:
json2ts --clipboard
Import and use the package in your Node.js or TypeScript project:
import { convertJsonToTs } from '@typeweaver/json2ts'; const json = { name: "John", age: 30 }; const tsInterface = convertJsonToTs(json); console.log(tsInterface); // Output: // interface Root { // name: string; // age: number; // }
Input JSON:
{ "name": "John", "age": 30, "address": { "city": "New York", "zip": "10001" } }
Generated TypeScript Interface:
interface Root { name: string; age: number; address: { city: string; zip: string; }; }
For detailed documentation and examples, visit the project wiki.
We welcome contributions!
Please see the CONTRIBUTING.md file for guidelines.
This project is licensed under the MIT License.
- Developed by Glincker.
- Part of the TypeWeaver ecosystem.
Have ideas or suggestions? Create an issue in the repository or join the discussion on GLINR Community.