<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: dileep kumar</title>
    <description>The latest articles on DEV Community by dileep kumar (@dileep1415).</description>
    <link>https://dev.to/dileep1415</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3856099%2F259b0a2f-1341-4523-8128-5d255c3fbca0.jpg</url>
      <title>DEV Community: dileep kumar</title>
      <link>https://dev.to/dileep1415</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dileep1415"/>
    <language>en</language>
    <item>
      <title>Stop Writing Zod Schemas by Hand: What I Learned After 40 API Endpoints</title>
      <dc:creator>dileep kumar</dc:creator>
      <pubDate>Wed, 01 Apr 2026 18:11:57 +0000</pubDate>
      <link>https://dev.to/dileep1415/stop-writing-zod-schemas-by-hand-what-i-learned-after-40-api-endpoints-5ape</link>
      <guid>https://dev.to/dileep1415/stop-writing-zod-schemas-by-hand-what-i-learned-after-40-api-endpoints-5ape</guid>
      <description>&lt;p&gt;*&lt;/p&gt;




&lt;p&gt;I have a confession to make.&lt;/p&gt;

&lt;p&gt;I spent three hours debugging a Zod schema on a Friday night. Not because the validation was complex. Not because the business logic was tricky.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Because the backend team renamed &lt;code&gt;avatar&lt;/code&gt; to &lt;code&gt;avatar_url&lt;/code&gt; in a deeply nested object. And I missed it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Three hours. For a single field name change.&lt;/p&gt;

&lt;p&gt;If you work with TypeScript and APIs, you know the drill. You have:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your TypeScript types&lt;/li&gt;
&lt;li&gt;Your Zod schemas for runtime validation
&lt;/li&gt;
&lt;li&gt;The actual JSON data from your API&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Three versions of the same data shape.&lt;/strong&gt; All have to stay in sync.&lt;/p&gt;

&lt;p&gt;And when something changes, you get to play detective. Scrolling through JSON responses, comparing field names, updating schemas, hoping you didn't miss anything.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Breaking Point
&lt;/h3&gt;

&lt;p&gt;I was maintaining a project with around 40 API endpoints. Each one returning nested objects, arrays, optional fields, nullable values.&lt;/p&gt;

&lt;p&gt;Every time the backend team deployed, I'd open my editor and do the same dance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Copy the new JSON response&lt;/li&gt;
&lt;li&gt;Compare it to my existing schema&lt;/li&gt;
&lt;li&gt;Update field by field&lt;/li&gt;
&lt;li&gt;Test&lt;/li&gt;
&lt;li&gt;Fix the typos I inevitably made&lt;/li&gt;
&lt;li&gt;Test again&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;I made the same mistakes over and over:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;❌ Forgetting to mark a field as optional&lt;br&gt;&lt;br&gt;
❌ Missing that an ID changed from string to number&lt;br&gt;&lt;br&gt;
❌ Not handling null values properly&lt;br&gt;&lt;br&gt;
❌ Typing &lt;code&gt;avatar&lt;/code&gt; instead of &lt;code&gt;avatar_url&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The bugs would show up in production. Users would get validation errors for fields that existed. Forms would fail because of fields that were actually optional.&lt;/p&gt;

&lt;p&gt;I was spending more time fixing schema bugs than building features.&lt;/p&gt;


&lt;h3&gt;
  
  
  The Idea
&lt;/h3&gt;

&lt;p&gt;I started wondering: &lt;em&gt;Why am I writing these manually?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The JSON response is right there. The schema is just a structured version of that same data. Couldn't something automate this?&lt;/p&gt;

&lt;p&gt;So I built a tool that does exactly that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You paste a JSON response. The tool looks at the actual data and figures out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What type is each field? (string, number, boolean, array, object)&lt;/li&gt;
&lt;li&gt;Are there any special patterns? (emails, URLs, UUIDs, dates)&lt;/li&gt;
&lt;li&gt;Which fields are always present vs sometimes missing?&lt;/li&gt;
&lt;li&gt;Which values can be null vs always have data?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then it generates a Zod schema.&lt;/p&gt;

&lt;p&gt;Not a perfect schema. But a correct, working schema that you can use immediately.&lt;/p&gt;


&lt;h3&gt;
  
  
  What It Actually Saves You
&lt;/h3&gt;

&lt;p&gt;Here's what a typical API response looks like in my project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"code"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"items"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"550e8400-e29b-41d4-a716-446655440000"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Something important"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"createdAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2024-03-15T10:30:00Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"metadata"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"views"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1234&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"tags"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"featured"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"popular"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"expires"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"pagination"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"page"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"limit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"hasNext"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Writing the schema for this manually would take me about 10 minutes. That's if I don't make any mistakes.&lt;br&gt;
`&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠 What It Caught Automatically
&lt;/h2&gt;

&lt;p&gt;One of the coolest parts of using this tool was noticing the details it picked up without any effort:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UUID format for the &lt;code&gt;id&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;ISO datetime format for &lt;code&gt;createdAt&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Nullable field for &lt;code&gt;expires&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Array of strings for &lt;code&gt;tags&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Would I have caught all that manually?&lt;/p&gt;

&lt;p&gt;Maybe.&lt;/p&gt;

&lt;p&gt;But I definitely would've spent time checking each field.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ The Unexpected Benefit
&lt;/h2&gt;

&lt;p&gt;The tool did something I didn't expect.&lt;/p&gt;

&lt;p&gt;When the generated schema didn't match my expectations, I started investigating the data more carefully. And that’s when things got interesting…&lt;/p&gt;

&lt;p&gt;👉 I found bugs I would've never noticed otherwise.&lt;/p&gt;




&lt;h3&gt;
  
  
  🐛 Real Example #1
&lt;/h3&gt;

&lt;p&gt;One time, the schema showed a field that was always &lt;code&gt;null&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So I dug into our API logs...&lt;/p&gt;

&lt;p&gt;Turns out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The backend had deprecated that field months ago
&lt;/li&gt;
&lt;li&gt;Nobody updated the documentation
&lt;/li&gt;
&lt;li&gt;I had been validating it incorrectly the whole time
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🐛 Real Example #2
&lt;/h3&gt;

&lt;p&gt;Another time, I noticed the generated schema had &lt;strong&gt;optional fields&lt;/strong&gt; that I had always treated as required.&lt;/p&gt;

&lt;p&gt;After checking:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Some API responses were omitting those fields
&lt;/li&gt;
&lt;li&gt;My validation was silently failing for certain users
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 The Realization
&lt;/h2&gt;

&lt;p&gt;The tool wasn't just saving me time.&lt;/p&gt;

&lt;p&gt;👉 It was making my code more accurate.&lt;/p&gt;




&lt;h2&gt;
  
  
  📚 What I Learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zod is powerful&lt;/strong&gt;, but writing schemas manually is still tedious
&lt;/li&gt;
&lt;li&gt;The real value is in &lt;strong&gt;validation&lt;/strong&gt;, not typing everything by hand
&lt;/li&gt;
&lt;li&gt;Automating repetitive work isn’t lazy — it’s efficient
&lt;/li&gt;
&lt;li&gt;API responses often have &lt;strong&gt;hidden patterns&lt;/strong&gt; you don’t notice
&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;working generated schema &amp;gt; a perfect schema you never write&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🚀 Try It Yourself
&lt;/h2&gt;

&lt;p&gt;I put this tool online because if I needed it, chances are others do too.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;ToolsVIA JSON to Zod Converter&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://www.toolsvia.app/json-to-zod" rel="noopener noreferrer"&gt;https://www.toolsvia.app/json-to-zod&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4k0l94p1c5lcu28gdwv6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4k0l94p1c5lcu28gdwv6.png" alt=" " width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  ✨ How It Works
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Paste your JSON
&lt;/li&gt;
&lt;li&gt;Click convert
&lt;/li&gt;
&lt;li&gt;Done
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No signup.&lt;br&gt;&lt;br&gt;
No data upload (everything runs in your browser).&lt;br&gt;&lt;br&gt;
No hidden costs.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 Final Thought
&lt;/h2&gt;

&lt;p&gt;If you're tired of playing detective with your API responses, give it a try with one of your real endpoints.&lt;/p&gt;

&lt;p&gt;It won’t solve all your problems…&lt;/p&gt;

&lt;p&gt;👉 But it might save you a Friday night or two 😄&lt;/p&gt;




&lt;h2&gt;
  
  
  💬 Your Turn
&lt;/h2&gt;

&lt;p&gt;What’s your most memorable debugging story?&lt;/p&gt;

&lt;p&gt;Ever spent hours on something that &lt;em&gt;should&lt;/em&gt; have been simple?&lt;/p&gt;

&lt;p&gt;Drop it in the comments — I’d love to know I’m not the only one 👇&lt;/p&gt;

</description>
      <category>api</category>
      <category>automation</category>
      <category>productivity</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
