---
name: json-to-pydantic
description: Converts JSON data snippets into Python Pydantic data models.
title: json-to-pydantic
canonical_url: https://skilld.dev/gh/rominirani/antigravity-skills/json-to-pydantic
last_updated: 2026-09-29T00:50:13.000Z
---

> **Skill from skilld.dev.** Follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [examples/input_data.json](https://skilld.dev/api/skills-raw/rominirani/antigravity-skills/json-to-pydantic/examples/input_data.json), [examples/output_model.py](https://skilld.dev/api/skills-raw/rominirani/antigravity-skills/json-to-pydantic/examples/output_model.py).
>
> If the user asked to install this Skill, run `npx skilld install rominirani/antigravity-skills/json-to-pydantic`. Install writes the Skill files into the project, so every session loads them.

# JSON to Pydantic Skill

This skill helps convert raw JSON data or API responses into structured, strongly-typed Python classes using Pydantic.

## Instructions

1. **Analyze the Input**: Look at the JSON object provided by the user.
2. **Infer Types**:
   - `string` -> `str`
   - `number` -> `int` or `float`
   - `boolean` -> `bool`
   - `array` -> `List[Type]`
   - `null` -> `Optional[Type]`
   - Nested Objects -> Create a separate sub-class.
   
3. **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`.
