|
1 |
| -# json-to-typescript |
2 |
| -Convert JSON to TypeScript interfaces effortlessly. An open-source tool for developers to generate TypeScript types from JSON objects quickly and securely. |
| 1 | + |
| 2 | +# JSON-to-TypeScript Converter |
| 3 | + |
| 4 | +Convert JSON to TypeScript interfaces effortlessly. |
| 5 | +An open-source tool for developers to generate TypeScript types from JSON objects quickly and securely. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## 🚀 Features |
| 10 | + |
| 11 | +- **Fast Conversion**: Generate TypeScript interfaces from JSON in seconds. |
| 12 | +- **Nested Objects Support**: Handles deeply nested structures with ease. |
| 13 | +- **Secure Offline Use**: No need to paste your data online—works locally. |
| 14 | +- **Customizable**: Future support for advanced type handling and customizations. |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## 📦 Installation |
| 19 | + |
| 20 | +Install the package via NPM: |
| 21 | + |
| 22 | +```bash |
| 23 | +npm install -g @typeweaver/json2ts |
| 24 | +``` |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## 🛠️ Usage |
| 29 | + |
| 30 | +### CLI |
| 31 | +Convert a JSON file to a TypeScript interface: |
| 32 | + |
| 33 | +```bash |
| 34 | +json2ts convert input.json output.ts |
| 35 | +``` |
| 36 | + |
| 37 | +Or use JSON from the clipboard: |
| 38 | + |
| 39 | +```bash |
| 40 | +json2ts --clipboard |
| 41 | +``` |
| 42 | + |
| 43 | +### Programmatic API |
| 44 | +Import and use the package in your Node.js or TypeScript project: |
| 45 | + |
| 46 | +```typescript |
| 47 | +import { convertJsonToTs } from '@typeweaver/json2ts'; |
| 48 | + |
| 49 | +const json = { name: "John", age: 30 }; |
| 50 | +const tsInterface = convertJsonToTs(json); |
| 51 | + |
| 52 | +console.log(tsInterface); |
| 53 | +// Output: |
| 54 | +// interface Root { |
| 55 | +// name: string; |
| 56 | +// age: number; |
| 57 | +// } |
| 58 | +``` |
| 59 | + |
| 60 | +--- |
| 61 | + |
| 62 | +## ✨ Example |
| 63 | + |
| 64 | +Input JSON: |
| 65 | +```json |
| 66 | +{ |
| 67 | + "name": "John", |
| 68 | + "age": 30, |
| 69 | + "address": { |
| 70 | + "city": "New York", |
| 71 | + "zip": "10001" |
| 72 | + } |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | +Generated TypeScript Interface: |
| 77 | +```typescript |
| 78 | +interface Root { |
| 79 | + name: string; |
| 80 | + age: number; |
| 81 | + address: { |
| 82 | + city: string; |
| 83 | + zip: string; |
| 84 | + }; |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## 📚 Documentation |
| 91 | + |
| 92 | +For detailed documentation and examples, visit the [project wiki](https://github.com/glincker/json-to-typescript/wiki). |
| 93 | + |
| 94 | +--- |
| 95 | + |
| 96 | +## 🤝 Contributing |
| 97 | + |
| 98 | +We welcome contributions! |
| 99 | +Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for guidelines. |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +## 📝 License |
| 104 | + |
| 105 | +This project is licensed under the [MIT License](LICENSE). |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +## 🌟 Acknowledgments |
| 110 | + |
| 111 | +- Developed by [Glincker](https://github.com/glincker). |
| 112 | +- Part of the **TypeWeaver** ecosystem. |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +## 📬 Feedback |
| 117 | + |
| 118 | +Have ideas or suggestions? Create an issue in the repository or join the discussion on [GLINR Community](https://community.glinr.dev). |
0 commit comments