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.
- Array Depth Detection: Automatically detects array depth and types.
- ISO Date Recognition: Converts valid ISO date strings to
Date
type. - Secure Offline Use: No need to paste your data online—works locally.
- Customizable Future Enhancements: Support for advanced type handling and customizable options in future updates.
You can install the package globally using any of these package managers:
Using NPM:
npm install -g @typeweaver/json2ts
Using Yarn:
yarn global add @typeweaver/json2ts
Using PNPM:
pnpm add -g @typeweaver/json2ts
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;
// }
{
"name": "John",
"age": 30,
"address": {
"city": "New York",
"zip": "10001"
}
}
interface Root {
name: string;
age: number;
address: {
city: string;
zip: string;
};
}
For more details, advanced examples, and troubleshooting, check the project wiki.
We welcome contributions!
If you want to enhance this project, please refer to the CONTRIBUTING.md file for guidelines.
This project is licensed under the MIT License.
- Developed by Glincker.
- Part of the GLINR ecosystem.
We’d love to hear from you!
Submit your ideas or suggestions via issues in the repository or join the discussion on the GLINR Community.