| Crates.io | mold-cli |
| lib.rs | mold-cli |
| version | 0.2.0 |
| created_at | 2025-12-06 14:26:27.382776+00 |
| updated_at | 2025-12-06 15:03:22.104992+00 |
| description | JSON to TypeScript/Zod/Prisma generator CLI |
| homepage | https://github.com/pumarogie/mold |
| repository | https://github.com/pumarogie/mold |
| max_upload_size | |
| id | 1970280 |
| size | 75,210 |
A blazing fast CLI tool that generates TypeScript types, Zod schemas, and Prisma models from JSON.
cargo install mold-cli
# Generate TypeScript interfaces
mold schema.json --ts
# Generate Zod schema
mold schema.json --zod
# Generate Prisma model
mold schema.json --prisma
# Generate all formats
mold schema.json --all
# Output to files instead of stdout
mold schema.json --all -o ./generated
# Custom type name (default: inferred from filename)
mold data.json --ts --name User
# Flat mode - keep nested objects inline
mold schema.json --ts --flat
Input (user.json):
{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"active": true,
"profile": {
"bio": "Developer",
"avatar": "https://example.com/avatar.png"
}
}
Output (--ts):
interface UserProfile {
avatar: string;
bio: string;
}
interface User {
active: boolean;
email: string;
id: number;
name: string;
profile: UserProfile;
}
Output (--zod):
import { z } from "zod";
const UserProfileSchema = z.object({
avatar: z.string(),
bio: z.string(),
});
const UserSchema = z.object({
active: z.boolean(),
email: z.string(),
id: z.number().int(),
name: z.string(),
profile: UserProfileSchema,
});
type UserProfile = z.infer<typeof UserProfileSchema>;
type User = z.infer<typeof UserSchema>;
export { UserProfileSchema, UserSchema };
export type { UserProfile, User };
Output (--prisma):
model UserProfile {
id Int @id @default(autoincrement())
avatar String
bio String
}
model User {
id Int @id @default(autoincrement())
active Boolean
email String
name String
}
[1, "two", true] become union types--flat--allUsage: mold [OPTIONS] <FILE>
Arguments:
<FILE> Path to JSON file
Options:
-t, --ts Generate TypeScript interfaces
-z, --zod Generate Zod schema
-p, --prisma Generate Prisma model
-a, --all Generate all formats
-o, --output <DIR> Output directory (default: stdout)
-n, --name <NAME> Root type name (default: inferred from filename)
--flat Keep nested objects inline (no extraction)
-h, --help Print help
-V, --version Print version
MIT