{"id":35151352,"url":"https://github.com/exanubes/typedef","last_synced_at":"2026-01-13T21:04:36.820Z","repository":{"id":330846701,"uuid":"1105361597","full_name":"exanubes/typedef","owner":"exanubes","description":"Create type definitions out of object structures","archived":false,"fork":false,"pushed_at":"2026-01-07T08:59:52.000Z","size":3841,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-07T11:37:07.696Z","etag":null,"topics":["codegen","golang","jsdoc","schema-generation","typedef","typescript","zod"],"latest_commit_sha":null,"homepage":"https://exanubes.github.io/typedef/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/exanubes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-27T13:53:03.000Z","updated_at":"2026-01-07T08:57:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/exanubes/typedef","commit_stats":null,"previous_names":["exanubes/typedef"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/exanubes/typedef","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exanubes%2Ftypedef","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exanubes%2Ftypedef/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exanubes%2Ftypedef/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exanubes%2Ftypedef/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exanubes","download_url":"https://codeload.github.com/exanubes/typedef/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exanubes%2Ftypedef/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28400688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codegen","golang","jsdoc","schema-generation","typedef","typescript","zod"],"created_at":"2025-12-28T15:45:45.314Z","updated_at":"2026-01-13T21:04:36.815Z","avatar_url":"https://github.com/exanubes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":" [![CI](https://github.com/exanubes/typedef/actions/workflows/ci.yml/badge.svg)](https://github.com/exanubes/typedef/actions/workflows/ci.yml)\n [![Release](https://github.com/exanubes/typedef/actions/workflows/release.yml/badge.svg)](https://github.com/exanubes/typedef/actions/workflows/release.yml)\n [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/exanubes/typedef/blob/master/LICENSE)\n [![Latest Release](https://img.shields.io/github/v/release/exanubes/typedef)](https://github.com/exanubes/typedef/releases)\n [![Go Report Card](https://goreportcard.com/badge/github.com/exanubes/typedef)](https://goreportcard.com/report/github.com/exanubes/typedef)\n [![Go Version](https://img.shields.io/github/go-mod/go-version/exanubes/typedef)](https://github.com/exanubes/typedef)\n\n# typedef\n\nConvert JSON to type definitions in multiple programming languages.\n\n`typedef` is a code generator that analyzes JSON input and produces strongly-typed definitions for your target language. Whether you're working with API responses, configuration files, or any JSON data, typedef helps you quickly generate type-safe code.\n\n## Table of Contents\n\n- [Features](#features)\n- [Quick Start](#quick-start)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Clipboard Support Setup](#clipboard-support-setup)\n- [Examples](#examples)\n- [Troubleshooting](#troubleshooting)\n- [Web Interface](#web-interface)\n- [License](#license)\n\n## Features\n\n- **Multiple Output Formats**: Generate Go structs, TypeScript interfaces, Zod schemas, or JSDoc typedefs\n- **Flexible Input**: Provide JSON via command flag, stdin pipe, or clipboard\n- **Smart Output**: Send generated types to clipboard, stdout, or file\n- **Intelligent Type Deduplication**: Automatically identifies and reuses structurally identical types\n- **Clipboard Integration**: Seamless clipboard support with automatic fallback on macOS and Linux\n- **Web Interface**: Also available as a browser-based tool at [https://exanubes.github.io/typedef](https://exanubes.github.io/typedef)\n\n## Quick Start\n\n```bash\n# Build the tool\ngo build -o typedef main.go\n\n# Generate Go types from JSON\n./typedef --format go --input '{\"name\": \"John\", \"age\": 30, \"active\": true}'\n\n# Output (copied to clipboard by default):\n# type Root struct {\n#     Active bool   \n#     Age    int    \n#     Name   string \n# }\n```\n\n## Installation\n\n### Option 1: Install via Homebrew (macOS/Linux)\n\nThe easiest way to install typedef on macOS or Linux:\n\n```bash\nbrew install exanubes/typedef/typedef\n```\n\nVerify installation:\n```bash\ntypedef version \n# {\n#   \"build_time\": \"2026-01-10T14:29:40Z\",\n#   \"commit_sha\": \"b33e9f0\",\n#   \"version\": \"0.0.21\"\n# }\n```\n\n### Option 2: Download Pre-built Binary\n\nDownload the latest release for your platform from [GitHub Releases](https://github.com/exanubes/typedef/releases):\n\n- **macOS (Intel)**: `typedef-darwin-amd64.tar.gz`\n- **macOS (Apple Silicon)**: `typedef-darwin-arm64.tar.gz`\n- **Linux (Intel/AMD)**: `typedef-linux-amd64.tar.gz`\n- **Linux (ARM)**: `typedef-linux-arm64.tar.gz`\n\nExtract and install:\n\n```bash\n# Download and extract (example for Linux amd64)\nwget https://github.com/exanubes/typedef/releases/latest/download/typedef-linux-amd64.tar.gz\ntar -xzf typedef-linux-amd64.tar.gz\n\n# The archive contains: typedef (binary), README.md, LICENSE\n# Verify it works\n./typedef --format go --input '{\"test\": 1}'\n\n# Add to PATH (optional)\nsudo mv typedef /usr/local/bin/\n```\n\n**Verify Download Integrity:**\n\n```bash\n# Download checksums\nwget https://github.com/exanubes/typedef/releases/latest/download/checksums.txt\n\n# Verify checksum\nsha256sum -c checksums.txt --ignore-missing\n```\n\n### Option 3: Build from Source\n\n**Prerequisites:** Go 1.24.4 or higher\n\n```bash\n# Clone the repository\ngit clone https://github.com/exanubes/typedef.git\ncd typedef\n\n# Build the CLI tool\ngo build -o typedef ./cmd/cli/main.go\n```\n\n**Verify the build:**\n\n```bash\n./typedef --format go --input '{\"test\": 1}' --target cli\n```\n\n## Usage\n\n### Input Methods\n\ntypedef accepts JSON input in three ways (checked in this order):\n\n1. **`--input` flag**: Explicit JSON string\n   ```bash\n   ./typedef --format go --input '{\"name\": \"Alice\", \"age\": 25}'\n   ```\n\n2. **stdin** (piped input):\n   ```bash\n   echo '{\"name\": \"Bob\", \"score\": 95}' | ./typedef --format typescript\n   ```\n\n3. **Clipboard** (automatic): If no input is provided, typedef reads from your clipboard\n   ```bash\n   # Copy JSON to clipboard, then run:\n   ./typedef --format zod\n   ```\n\n### Output Targets\n\nControl where generated types are sent using the `--target` flag:\n\n- **`clipboard`** (default): Copies output to clipboard for easy pasting\n  ```bash\n  ./typedef --format go --input '{\"data\": true}'\n  # Output copied to clipboard automatically\n  ```\n\n- **`cli`**: Prints to stdout\n  ```bash\n  ./typedef --format typescript --target cli --input '{\"id\": 1}'\n  ```\n\n- **`file`**: Saves to a file (use `--output-path` to specify location, or it will fallback to default location) \n  ```bash\n  ./typedef --format go --input '{\"user\": \"john\"}' --target file --output-path ./types.go\n  ```\n\n### Supported Formats\n\n| Format | Flag Values | Output |\n|--------|-------------|--------|\n| Go | `go`, `golang` | Go structs |\n| TypeScript | `typescript`, `ts` | TypeScript interfaces |\n| Zod | `zod`, `ts-zod` | Zod schema definitions |\n| JSDoc | `jsdoc` | JSDoc typedef comments |\n\n### Command Flags Reference\n\n| Flag  | Description | Default |\n|------|-------------|---------|\n| `--format` | Output format (go/typescript/zod/jsdoc) | Required |\n| `--input`  | JSON input string | Uses stdin or clipboard |\n| `--target`  | Output target (clipboard/cli/file) | `clipboard` |\n| `--output-path` | File path when using `--target file` | `./typedef.txt` |\n\n## Clipboard Support Setup\n\ntypedef can read JSON from your clipboard and copy generated types back to it automatically. Support varies by platform:\n\n| Platform | Requirements               | Setup Needed |\n|----------|----------------------------|--------------|\n| macOS    | pbcopy, pbpaste (built-in) | None         |\n| Linux    | wl-clipboard, xclip        | Yes          |\n\n### macOS\n\nNo setup required! typedef uses the built-in `pbcopy` and `pbpaste` utilities that come with macOS.\n\n### Linux\n\n#### wl-clipboard \n\nInstall the `wl-clipboard` package:\n\n```bash\n# Debian/Ubuntu\nsudo apt-get install wl-clipboard\n\n# Fedora\nsudo dnf install wl-clipboard\n\n# Arch Linux\nsudo pacman -S wl-clipboard\n```\n\nVerify installation:\n```bash\nwhich wl-copy wl-paste\n```\n\n#### xclip \n\nInstall the `xclip` package:\n\n```bash\n# Debian/Ubuntu\nsudo apt-get install xclip\n\n# Fedora\nsudo dnf install xclip\n\n# Arch Linux\nsudo pacman -S xclip\n```\n\nVerify installation:\n```bash\nwhich xclip\n```\n\n### Automatic Fallback\n\nIf supported clipboard tools aren't detected, typedef will automatically fall back to stdout output without errors:\n\n```\nINFO: required dependencies for clipboard not detected. Falling back to cli target\n```\n\nThe tool continues to work normally, printing output to your terminal instead. You can also explicitly use `--target cli` or `--target file` to bypass clipboard functionality.\n\n## Examples\n\n### Basic Usage\n\n```bash\n# Generate Go struct\ntypedef --format go --input '{\"username\": \"alice\", \"email\": \"alice@example.com\"}'\n\n# Generate TypeScript interface\ntypedef --format typescript --input '{\"id\": 1, \"title\": \"Hello\", \"published\": true}'\n\n# Generate Zod schema\ntypedef --format zod --input '{\"age\": 30, \"name\": \"Bob\"}'\n\n# Generate JSDoc typedef\ntypedef --format jsdoc --input '{\"count\": 5, \"items\": [\"a\", \"b\"]}'\n```\n\n### Piped Input\n\n```bash\n# From echo\necho '{\"status\": \"success\", \"data\": {\"id\": 123}}' | typedef --format go\n\n# From file\ncat config.json | typedef --format typescript\n\n# From API response with curl\ncurl -s https://api.example.com/user/1 | typedef --format go\n```\n\n### Clipboard Workflow\n\n```bash\n# 1. Copy JSON from anywhere (browser, editor, etc.)\n# 2. Run typedef\ntypedef --format typescript\n\n# 3. Generated TypeScript interface is now in your clipboard\n# 4. Paste directly into your code editor\n```\n\n### File Output\n\n```bash\n# Save Go types to file\n./typedef --format go --input '{\"name\": \"test\"}' --target file --output-path ./models/user.go\n\n# Process API response and save\ncurl -s https://api.example.com/data | ./typedef --format typescript --target file --output-path ./types/api.ts\n```\n\n### Real-World Scenarios\n\n**Converting API Response to TypeScript:**\n```bash\ncurl -s https://jsonplaceholder.typicode.com/users/1 | ./typedef --format typescript\n```\n\n**Generating Go Structs from Config:**\n```bash\ncat settings.json | ./typedef --format go --target file --output-path ./config/types.go\n```\n\n**Creating Zod Schemas for Form Validation:**\n```bash\n./typedef --format zod --input '{\"email\": \"user@example.com\", \"age\": 25, \"subscribe\": true}'\n```\n\n**Using with jq for Complex JSON:**\n```bash\n# Extract specific data with jq, then generate types\ncurl -s https://api.github.com/repos/golang/go | jq '.owner' | ./typedef --format typescript\n```\n\n## Troubleshooting\n\n### Clipboard Issues\n\n**Problem**: \"Clipboard support disabled\" message on Linux\n\n**Solution**: Install the required clipboard tool for your display server:\n- Wayland: `sudo apt-get install wl-clipboard`\n- X11: `sudo apt-get install xclip`\n\n**Problem**: Clipboard not working after installation\n\n**Solution**: Verify the tools are in your PATH:\n```bash\nwhich wl-copy wl-paste  # Wayland\nwhich xclip              # X11\n```\n\n### Invalid JSON Errors\n\n**Problem**: \"Failed to parse JSON\" or similar errors\n\n**Solution**: Validate your JSON before passing to typedef:\n```bash\n# Using jq to validate\necho '{\"test\": 1}' | jq .\n\n# Using online validators\n# https://jsonlint.com/\n```\n\n### Platform-Specific Issues\n\n**Linux: Permission denied**\n```bash\n# Make the binary executable\nchmod +x typedef\n```\n\n**macOS: \"cannot be opened because the developer cannot be verified\"**\n```bash\n# Allow the binary in System Preferences \u003e Security \u0026 Privacy\n# Or build from source as shown in Installation section\n```\n\n## Web Interface\n\nPrefer a browser-based tool? typedef is also available as a web application at:\n\n**[https://exanubes.github.io/typedef](https://exanubes.github.io/typedef)**\n\nThe web version offers the same type generation capabilities with a graphical interface, perfect for quick conversions without installing the CLI tool.\n\n## License\n\nMIT License - see LICENSE file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexanubes%2Ftypedef","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexanubes%2Ftypedef","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexanubes%2Ftypedef/lists"}