https://github.com/MariusAlch/json-to-ts
Convert jsons to typescript interfaces
https://github.com/MariusAlch/json-to-ts
Last synced: about 4 hours ago
JSON representation
Convert jsons to typescript interfaces
- Host: GitHub
- URL: https://github.com/MariusAlch/json-to-ts
- Owner: MariusAlch
- Created: 2017-04-16T16:24:01.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-04-18T19:45:07.000Z (about 1 year ago)
- Last Synced: 2024-11-13T09:45:48.429Z (6 months ago)
- Language: TypeScript
- Homepage:
- Size: 83 KB
- Stars: 410
- Watchers: 6
- Forks: 58
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

# Json to TS
### Convert json object to typescript interfaces
# Example
### Code
```javascript
const JsonToTS = require('json-to-ts')const json = {
cats: [
{name: 'Kittin'},
{name: 'Mittin'}
],
favoriteNumber: 42,
favoriteWord: 'Hello'
}JsonToTS(json).forEach( typeInterface => {
console.log(typeInterface)
})
```### Output:
```typescript
interface RootObject {
cats: Cat[];
favoriteNumber: number;
favoriteWord: string;
}
interface Cat {
name: string;
}
```## Converter
- Array type merging (**Big deal**)
- Union types
- Duplicate type prevention
- Optional types
- Array types# Setup
```sh
$ npm install --save json-to-ts
```