Turn Any JSON Into TypeScript Interfaces ...

Turn Any JSON Into TypeScript Interfaces and Go Structs

Dec 01, 2026
1

Stop typing API types by hand. Paste a sample, get clean types, and polish them in two minutes.

Generate TypeScript interfaces and Go structs from JSON with free DevDesk App tools

From a raw API response to typed code, with autocomplete.

You just connected a new API. The response has 30 fields, three nested objects and an array of orders. Now you need types for it, in TypeScript for the frontend and maybe in Go for the backend.

Writing them by hand is slow, boring and easy to get wrong. One typo in a field name and the compiler happily trusts a property that never arrives.

Two free tools on DevDesk App do the heavy lifting: JSON to TypeScript and JSON to Go Struct. Paste a sample, copy the result, and spend your time on the parts that need a human.

In this guide you will learn:

  • How to generate TypeScript interfaces from a JSON response

  • How to generate Go structs with correct json tags

  • The four quick edits that make generated types production ready

  • How to use the types safely with fetch

JSON to TypeScript in One Paste

Set the root name to User and paste:

{
  "id": 42,
  "name": "Asha",
  "email": null,
  "tags": ["admin", "dev"],
  "address": {"city": "Berlin", "zip": "10115"},
  "orders": [{"orderId": "A1", "total": 49.5, "paid": true}]
}

You get:

interface User {
  id: number;
  name: string;
  email: null;
  tags: string[];
  address: Address;
  orders: Order[];
}

interface Order {
  orderId: string;
  total: number;
  paid: boolean;
}

interface Address {
  city: string;
  zip: string;
}

The DevDesk App JSON to TypeScript tool generating User, Order and Address interfaces

Tested live: nested objects become their own named interfaces.

Notice the smart naming. The nested address object becomes an Address interface, and the plural orders array gets a singular Order type. If objects in one array have different shapes, you get Order and Order2 joined in a union, which is your hint to merge them.

👉 Try it: https://www.devdeskapp.com/json-to-types

JSON to Go Struct With Tags

For Go, paste a sample into JSON to Go Struct:

{"id": 7, "user_name": "asha", "active": true, "tags": ["a", "b"], "address": {"city": "Berlin"}}

and get:

type User struct {
    ID       int      `json:"id"`
    UserName string   `json:"user_name"`
    Active   bool     `json:"active"`
    Tags     []string `json:"tags"`
    Address  struct {
        City string `json:"city"`
    } `json:"address"`
}

The DevDesk App JSON to Go Struct tool generating a struct with json tags

Exported field names, original keys kept in the tags.

Good Go style comes for free: user_name becomes UserName, id becomes ID, and every field keeps its original key in the json tag, so encoding/json maps it perfectly.

👉 Try it: https://www.devdeskapp.com/json-to-go-struct

Four Quick Edits for Production Ready Types

A single sample cannot know everything. These small edits make a big difference:

1. Mark optional fields. If some records have a coupon and others do not, merge the two interfaces and add a question mark:

interface Order {
  orderId: string;
  total: number;
  paid: boolean;
  coupon?: string;
}

In Go, add ,omitempty to the tag for fields that may be absent.

2. Fix nulls. A field that was null in your sample is typed as null. If it is usually a string, write email: string | null. In Go, use a pointer such as *string.

3. Keep big IDs as strings. Numbers above 2^53 lose precision in JavaScript. If your API sends long IDs, type them as string in TypeScript and int64 or string in Go.

4. Treat dates on purpose. JSON has no date type, so dates arrive as strings. Keep them as string in TypeScript, or switch to time.Time in Go when the value is ISO 8601.

A friendly tip: use the richest sample you have, one that includes every optional field you know about. Better samples give better types.

Using the Types With fetch

async function getUser(id: number): Promise<User> {
  const res = await fetch(`/api/users/${id}`);
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
  return (await res.json()) as User;
}

const user = await getUser(42);
user.address.city;    // string, with autocomplete
user.orders[0].total; // number

The as User cast gives you autocomplete and compile time checks, but it does not validate data at runtime. For APIs that might change, check the response with a schema library, or try the free JSON Schema Validator while you design: https://www.devdeskapp.com/json-schema-validator

Your JSON Stays Private

Types are generated locally in your browser. Real API responses with customer data are never uploaded, which makes the tools safe to use at work.

What We Build at DevDesk App

Next to 340+ free developer tools, our team builds real projects for companies around the world:

  • n8n workflow automation: API to API integrations, ecommerce order pipelines, AI agents with approval steps, and reports to Slack or Sheets. See https://www.devdeskapp.com/n8n-automation-services

  • Custom n8n nodes and API integrations: typed, tested community nodes for your own API, plus workflow audits and self hosted n8n setup.

  • Tool and web development: custom internal tools, converters and dashboards for your team, built fast and privacy first.

Every project starts with a short message and gets a fixed quote. Email [email protected] or reach us at https://www.devdeskapp.com/contact

Final Thoughts

Generated types are a fantastic first draft. Paste a sample, copy the result, add the four quick edits, and you get safe, typed code in minutes instead of an afternoon. Bookmark both tools for the next time a new API lands on your desk.

Happy typing!

Подобається цей допис?

Купити для DevDesk App каву

Більше від DevDesk App