Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 interface or type from 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 indentation

Input (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

Releases

Packages

Used by

Contributors

Languages