This skill helps convert raw JSON data or API responses into structured, strongly-typed Python classes using Pydantic.
Instructions
Analyze the Input: Look at the JSON object provided by the user.
Infer Types:
string -> str
number -> int or float
boolean -> bool
array -> List[Type]
null -> Optional[Type]
Nested Objects -> Create a separate sub-class.
Follow the Example:
Review examples/ to see how to structure the output code. notice how nested dictionaries like preferences are extracted into their own class.
Input: examples/input_data.json
Output: examples/output_model.py
Style Guidelines
Use PascalCase for class names.
Use type hints (List, Optional) from typing module.
If a field can be missing or null, default it to None.
1---2name: json-to-pydantic3description: JSON to Pydantic Skill4---5# JSON to Pydantic Skill67This skill helps convert raw JSON data or API responses into structured, strongly-typed Python classes using Pydantic.89## Instructions10111. **Analyze the Input**: Look at the JSON object provided by the user.122. **Infer Types**:13 - `string` -> `str`14 - `number` -> `int` or `float`15 - `boolean` -> `bool`16 - `array` -> `List[Type]`17 - `null` -> `Optional[Type]`18 - Nested Objects -> Create a separate sub-class.19203. **Follow the Example**:21 Review `examples/` to see how to structure the output code. notice how nested dictionaries like `preferences` are extracted into their own class.2223 - Input: `examples/input_data.json`24 - Output: `examples/output_model.py`2526## Style Guidelines27- Use `PascalCase` for class names.28- Use type hints (`List`, `Optional`) from `typing` module.29- If a field can be missing or null, default it to `None`.
Run npx skillmds@latest add comeonoliver/json-to-pydantic in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
JSON to Pydantic Skill It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.