tsj-cli
v0.5.0
Published
Generate TypeScript interfaces or types from JSON via the command line.
Maintainers
Readme
tsj-cli
tsj-cli is a lightweight CLI tool that generates TypeScript interfaces or type aliases from a JSON file.
📦 NPM: tsj-cli
💻 GitHub: iaseth/tsj-cli
✨ Features
- Generates TypeScript
interfaceortypefrom JSON - Supports custom indentation: 2 spaces (default), 4 spaces, or tabs
- Simple command-line usage
- Minimal and dependency-free output
🚀 Installation
npm i -g tsj-cli@latest🛠 Usage
tsj <paths/to/file.json> [--type | --interface] [--tabs | --spaces]Examples
tsj user.json # default: interface, 2 spaces
tsj user.json --type # generates a type alias
tsj user.json --spaces # uses 4 spaces for indentation
tsj user.json --tabs # uses tabs instead
tsj user.json --type --tabs # type alias with tab indentationInput (user.json)
{
"id": 1,
"name": "Alice",
"isAdmin": false,
"tags": ["dev", "ts"],
"profile": {
"age": 30,
"location": "Earth"
}
}Output (interface)
interface User {
id: number;
name: string;
isAdmin: boolean;
tags: string[];
profile: {
age: number;
location: string;
};
}📁 Project Structure
tsj-cli/
├── src/ # Source code (written in TypeScript)
├── dist/ # Transpiled JavaScript output
├── package.json
├── tsconfig.json
├── .gitignore
├── .npmignore
└── README.md🧪 Development
# Install dependencies
npm install
# Build
npm run build
# Test locally
ts-node src/index.ts data.json --type --tabs
# Link globally for local use
npm link
tsj data.json --interface📝 License
MIT © iaseth
