Skip to content

Convert JSON to TypeScript interfaces effortlessly. An open-source tool for developers to generate TypeScript types from JSON objects quickly and securely.

License

Notifications You must be signed in to change notification settings

GLINCKER/json-to-typescript

Repository files navigation

JSON-to-TypeScript Converter

Convert JSON to TypeScript interfaces effortlessly.
An open-source tool for developers to generate TypeScript types from JSON objects quickly and securely.


🚀 Features

  • 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.

📦 Installation

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

🛠️ Usage

Programmatic API

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;
// }

✨ Example

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;
  };
}

📚 Documentation

For more details, advanced examples, and troubleshooting, check the project wiki.


🤝 Contributing

We welcome contributions!
If you want to enhance this project, please refer to the CONTRIBUTING.md file for guidelines.


📝 License

This project is licensed under the MIT License.


🌟 Acknowledgments

  • Developed by Glincker.
  • Part of the GLINR ecosystem.

📬 Feedback

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.