If you have used Zod, you already understand 70 to 80% of Pydantic. The mental model transfers almost one-to-one.

This is the second post of my TypeScript-to-Python journey. This time I learnt about Pydantic, a runtime validation library for Python. It is like Zod, but for Python.
For context, I am a full-stack developer from India, expanding into AI engineering. Almost all the GenAI roles I am seeing require Python. My plan is very simple: learn what is needed to build, rather than going through yet another course.
This week's topic is: how do you trust the JSON an LLM returns? In TypeScript we have Zod or similar runtime validation libraries. We define the schema and call .parse.
Similarly, in Python we have Pydantic. The thing which surprised me was the mapping of the mental model. It is nearly one-to-one:
Notice: Pydantic needs no separate
z.inferstep as the class is both the schema and the type.BaseModelis imported frompydantic.
One other surprising thing for me was to know that Python does not enforce types at runtime. I knew Python is a dynamically typed language, but I also knew that it has type hints and assumed that it enforces types at runtime. I am happy to know that I was wrong.
I also got to know that AI models support something called structured output, where we can pass a JSON schema to the model and it will return valid JSON matching your schema. For example, Anthropic supports structured output via the output_format property:
Main takeaway: if you have used Zod or a similar library, you already understand 70 to 80% of Pydantic. The mental model transfers as is, only some syntax and features change.
Thanks for reading. :) See you in the next lesson.

Coming from npm and node_modules, Python tooling felt alien until I found uv. Here is the 1:1 mapping that made it click.

A deep walk-through of web security for JS developers: same-origin policy, CORS, XSS, CSRF, clickjacking, CSP, secrets, supply chain, plus 2026 case studies from axios and Vercel. Built as an interview-ready reference for anyone who (like me) has to re-learn this every few months.

Say goodbye to date-handling nightmares! Learn how the new Temporal API makes working with dates and times in JavaScript a breeze.