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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

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.
  • Secure Offline Use: No need to paste your data online—works locally.
  • Customizable: Future support for advanced type handling and customizations.

📦 Installation

Install the package via NPM:

npm install -g @typeweaver/json2ts

🛠️ Usage

CLI

Convert a JSON file to a TypeScript interface:

json2ts convert input.json output.ts

Or use JSON from the clipboard:

json2ts --clipboard

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 detailed documentation and examples, visit the project wiki.


🤝 Contributing

We welcome contributions!
Please see the CONTRIBUTING.md file for guidelines.


📝 License

This project is licensed under the MIT License.


🌟 Acknowledgments

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

📬 Feedback

Have ideas or suggestions? Create an issue in the repository or join the discussion on GLINR Community.