Generate TypeScript, Python, and Go types from JSON Schema. One binary, zero dependencies.
brew tap mirpo/homebrew-tools
brew install schemagengo install github.com/mirpo/schemagen@latestDownload from GitHub Releases.
# Generate TypeScript
schemagen generate schemas/ --out-ts ./types
# Generate Python (Pydantic v2)
schemagen generate schemas/ --out-py ./models
# Generate Go
schemagen generate schemas/ --out-go ./models
# All three at once
schemagen generate schemas/ --out-ts ./types --out-py ./models --out-go ./modelsThese flags are available for all commands:
-v, --verbose- Enable verbose/debug logging--json- Output logs in JSON format
Generate code from JSON Schema files.
schemagen generate <input> [flags]Flags:
Output directories:
--out-ts <dir>- TypeScript output directory--out-py <dir>- Python output directory--out-go <dir>- Go output directory
General:
--extract-inline- Extract inline enums and nested objects to top-level types--output-strategy <strategy>- Output strategy:bundle,multifile, orbundledeps(default:multifile)--disable-headers- Remove generated file headers--disable-timestamp- Remove timestamp from headers
TypeScript-specific:
--ts-unknown-any- Useunknowninstead ofanyfor untyped schemas--ts-additional-properties- Add index signatures for additionalProperties
Python-specific:
--py-snake-case-field- Convert field names to snake_case with JSON alias--py-additional-properties- Addmodel_config = ConfigDict(extra='allow')for schemas with additionalProperties
Go-specific:
--go-package <name>- Package name for generated files (default:models)--go-pointers- Use pointers for optional fields (default:true)--go-omit-empty- Add omitempty to optional JSON tags (default:true)--go-module-path <path>- Go module path for absolute imports (e.g.,github.com/org/project)
Check if schemas are valid JSON Schema.
schemagen validate schemas/Flags:
--format <format>- Output format:textorjson(default:text)
Check if generated code matches schemas. Returns exit code 2 if drift detected. Useful for CI.
schemagen verify schemas/ --out-ts ./typesFlags:
--quiet- Suppress output (only exit codes)
Show what would change if you regenerated.
schemagen diff schemas/ --out-ts ./types- Interfaces with JSDoc comments
@formatannotations (uuid, email, etc.)- Union types for enums
- Auto-generated barrel exports (
index.ts)
- Pydantic v2 BaseModel classes
- Field constraints (min, max, pattern)
- Format types (EmailStr, UUID, datetime)
- Enum classes
- Optional:
model_config = ConfigDict(extra='allow')for additionalProperties (use--py-additional-properties) - Auto-generated barrel exports (
__init__.py)
- Structs with JSON tags
- Go validator tags (min, max, email, uuid, etc.)
- Embedded structs for allOf composition
- UUID and time.Time format types
- Configurable pointer usage and package naming
MIT