貼上 JSON Schema
拖放任意 Draft 2020-12 或 Draft-07 Schema 檔案。
在本機從現有的 OpenAPI 或 JSON Schema 檔案產生乾淨的 Python BaseModel 定義 — 保留 Literal 列舉與 Field(...) 中繼資料。
選擇 .schema.json
將 enum 對應為 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 Schema 驗證 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)。