粘贴 JSON Schema
拖放任意 Draft 2020-12 或 Draft-07 Schema 文件。
在本地从现有 OpenAPI 或 JSON Schema 文件直接生成规范的 Python BaseModel 定义 — 完整保留 Literal 枚举与 Field(...) 元数据。
选择 .schema.json 文件
将枚举映射为 Literal,约束映射为 Field(ge=..., description=...).json
零上传限制 · 运行于浏览器内存
Field() 约束与 Literal 枚举
{
"type": "object",
"required": ["invoiceId", "total"],
"properties": {
"invoiceId": { "type": "string", "description": "Unique invoice ID" },
"total": { "type": "number", "minimum": 0 },
"status": { "type": "string", "enum": ["draft", "paid", "void"] }
}
}invoice.schema.json 的浏览器本地输出预览| 属性 | 源格式:JSON Schema | 目标格式:Pydantic |
|---|---|---|
| 文件扩展名 | .schema.json | .py |
| MIME 类型 | application/schema+json | text/x-python |
| 结构类型 | 强类型 Schema | 强类型 Schema |
| 编码方式 | UTF-8 纯文本 | UTF-8 纯文本 |
| 嵌套支持 | 是 | 是 |
| LLM Token 效率 | 中 | 中 |
| Schema / 类型约束 | 是 | 是 |
| 最佳适用场景 | 跨语言 API 负载契约、OpenAI/Anthropic 结构化输出、表单校验以及 AJV 运行时验证。 | FastAPI 后端接口、Python AI 智能体结构化输出、LangChain/OpenAI Python SDK 以及类型化 ETL 校验。 |
将 JSON Schema 规范(enum、minimum、description、$ref)转换为带 Field() 边界约束的 Python Pydantic v2 BaseModel 类。
拖放任意 Draft 2020-12 或 Draft-07 Schema 文件。
选择 Pydantic v2 或 v1、设置根类名并勾选保留字段描述。
下载可直接用于 FastAPI、PydanticAI 或 ETL 校验的 .py 模型文件。
将 JSON Schema($defs、$ref、enum、minimum、minLength、description)编译为地道的 Zod v4 TypeScript 代码。
在本地使用 AJV 针对 Draft 2020-12 或 Draft-07 规范校验 JSON 负载,并定位精确的 JSON Pointer 错误路径。
将示例 JSON 转换为严格的 OpenAI response_format(strict: true、additionalProperties: false)或 Anthropic Tool Use Schema。
enum 在 Python 中如何表示?字符串枚举会生成简洁的 Python Literal[...] 类型注解,获得 Pydantic v2 的原生验证支持。
minimum 和 description 会保留吗?会的。数值边界与字段说明会自动生成为 Field(ge=..., description=...)。
required 的可选属性如何建模?不在 required 数组中的属性在 v2 模式下会生成 T | None = None(v1 模式下为 Optional[T] = None)。