Axonix Tools
Why You Should Stop Writing TypeScript Interfaces Manually
Back to Insights
TypeScriptProductivityWeb Development

Why You Should Stop Writing TypeScript Interfaces Manually

5 min read
Reviewed:

Manually typing API responses is a waste of developer time. Here's how to automate type generation from JSON and get Zod schemas for free.

I've typed out thousands of interfaces. It was all wasted time.

After six years of TypeScript development, I sat down one day and realized something annoying: I've probably spent two hundred hours manually transcribing JSON responses into interface definitions. Two hundred hours of copying field names, guessing whether something is a string or a nullable string, and writing nested interfaces for objects inside objects inside arrays.

That's over eight full days of my life. Gone. Typing boilerplate that a machine could generate in milliseconds.

TypeScript is now one of the most-used languages on GitHub. Over 85 percent of developers who try it keep using it. The type safety is valuable. The type writing is tedious.

The "any" problem

When developers get frustrated with typing, they do something predictable:

const data: any = await response.json();

They tell themselves they'll fix it later. They never do.

Codebases with heavy any usage lose most of the benefits of TypeScript. You're paying the compilation cost without getting the safety guarantees. The type checker can't catch mistakes if you've told it that everything is any.

I've seen production bugs that would have been caught at compile time if someone had typed the API response properly. Instead, they used any, the bug slipped through, and a user saw a broken page.

The workflow that changed everything

After wasting years on manual typing, I automated the entire process:

  1. Hit an API endpoint using Postman, curl, or the browser devtools network tab.
  2. Copy the JSON response.
  3. Paste it into the Type Converter.
  4. Get a perfect TypeScript interface definition in seconds.

That's it. What used to take ten to fifteen minutes of careful transcription now takes ten seconds. And it's more accurate than anything I'd write by hand, because the tool doesn't make typos.

Beyond TypeScript: runtime validation with Zod

Here's something many developers don't think about until it bites them: TypeScript interfaces only exist at compile time. They evaporate when the code runs.

If your API sends malformed data, TypeScript won't catch it. The request succeeds, your type is wrong, and you get a runtime error somewhere deep in your component tree. The error message tells you that undefined doesn't have a property called name. Good luck figuring out which API response caused it.

This is why runtime validation libraries like Zod have become essential. Zod lets you define a schema that validates data at runtime and infers TypeScript types from that schema. You get both compile-time safety and runtime validation from a single definition.

The Type Converter generates Zod schemas automatically from your JSON. You get:

  • Compile-time type safety from TypeScript.
  • Runtime validation from Zod.
  • Zero manual typing.

Here's what the output looks like for a simple user object:

import { z } from 'zod';

export const UserSchema = z.object({
  id: z.number(),
  name: z.string(),
  email: z.string().email(),
  avatar: z.string().nullable(),
  createdAt: z.string(),
});

export type User = z.infer<typeof UserSchema>;

Now when you receive data from the API, you validate it:

const response = await fetch('/api/user/123');
const json = await response.json();
const user = UserSchema.parse(json);

If the API sends unexpected data, Zod throws a descriptive error at the boundary instead of letting bad data propagate through your application.

Edge cases the tool handles

Real-world API responses are messy. Here's what the converter deals with automatically:

Nullable fields. When a value is sometimes null, the tool marks it as nullable. string | null in TypeScript, z.string().nullable() in Zod.

Union types. When a field contains different types across different responses, the tool creates a proper union. If status is sometimes a string and sometimes a number, you get string | number.

Nested objects. The tool generates separate interface definitions for nested structures instead of inlining everything. This keeps your types readable and reusable.

Arrays. It correctly types array contents, including arrays of objects, arrays of primitives, and mixed-type arrays.

Date strings. ISO date strings can be automatically typed as Date types instead of string, with Zod validation that checks the format.

Optional fields. When a field is sometimes missing from the response, the tool marks it as optional instead of required.

Support for other languages

It's not just TypeScript. The tool handles multiple target languages:

Go. Generates properly tagged structs for JSON unmarshalling with correct type mappings.

Python. Creates Pydantic models for FastAPI and Django applications.

Java. Outputs classes with Jackson annotations for Spring Boot applications.

C#. Produces classes ready for System.Text.Json serialization.

When manual typing is still worth it

Automation isn't always the right answer. There are cases where you should write types by hand:

When the API documentation is better than the actual response. Sometimes APIs return data that doesn't match their documentation. If you know the intended structure and the actual response is buggy, write the type for the intended structure and let Zod validation catch the mismatch.

When you need to add business logic to your types. Branded types, custom validators, and computed fields need manual definition. The converter gives you the base structure. You add the domain-specific logic.

When the response is enormous. A JSON response with five hundred fields probably shouldn't be typed as a single interface. Break it into smaller, focused types that represent the parts you actually use.

Stop trading brainpower for boilerplate

Your time has value. Every minute spent transcribing JSON into interfaces is a minute not spent on actual logic, actual debugging, or actual feature work.

The Type Converter runs in your browser. Your JSON never leaves your device. It handles production data privately and generates code in seconds.

Use it. Your future self will stop spending eight days typing boilerplate.

Written by Axonix Team

Axonix Team - Technical Writer @ Axonix

Share this article

Discover More

View all articles

Need a tool for this workflow?

Axonix provides 100+ browser-based tools for practical development, design, file, and productivity tasks.

Explore Our Tools