Nouplo

JSON to types

A sample in, a type out.

Examples temporarily replace the input and settings. You can restore your previous work.

0 characters
Output
Paste or type above to see the result here.

Your files stay on your device

This tool runs entirely in your browser. What you paste is processed on your device and is never sent to a server, so it is safe to use with tokens, keys and unpublished text.

Example

Example: two web-shop orders turned into TypeScript interfaces, with an optional coupon

A small US online shop is typing its order API. The developer pastes two orders as a JSON array: 1041 for Megan Hughes, a mug and a T-shirt, coupon SPRING10 and gift_note null; and 1042 for James Patel, one cap, a gift note and no coupon field at all. Settings: TypeScript, name Order, indent 2 spaces.

  1. The JSON starts with an array, so the type describes one order and is named Order. A last line adds OrderList = Order[] for the whole response.
  2. Both orders are read, not just the first: coupon is in 1041 but missing from 1042, so it comes out coupon?: string. gift_note was null once and text once, so it is null | string.
  3. customer, each line of items and shipping are objects, so each gets its own interface named after its field: Customer, Item (items made singular) and Shipping.
  4. Prices 12.5, 24 and 5.99 all become number. TypeScript has no separate type for whole numbers or cents.
Field In the two orders Type written
id 1041, 1042number
placed_at "2026-03-14T09:12:00Z"string
customer name and emailCustomer
items 2 lines, then 1 lineItem[]
coupon "SPRING10", then missingstring, optional (coupon?)
gift_note null, then "Happy birthday, Dad!"null | string
shipping method and costShipping

4 interfaces (Order, Customer, Item, Shipping) plus OrderList: 27 lines to paste into types.ts. Read them over: placed_at is really a date, and method is only ever ground or express, so you might tighten it to 'ground' | 'express'. Two samples cannot tell you that.

How it works

  1. Paste a sample response. One real record is better than a made-up one.
  2. Choose TypeScript, Go or Zod.
  3. Name the top-level type, or leave it as Root.
  4. Copy the result. Read it over — inference from one sample is a first draft, not a specification.

Frequently asked questions

Does it look at every element of an array, or just the first?
Every one. [{a:1},{a:1,b:2}] gives b as optional rather than pretending it does not exist, which is the mistake that makes generated types annoying two weeks later.
What does it do with null?
Widens rather than narrows. A field that was null once is a field that can be null, so in TypeScript it becomes a union and in Go a pointer. That is nearly always what the API actually does.
Do repeated objects get one type or many?
One. Objects with the same field names share a named type, so a list of fifty users produces one User interface rather than fifty.
Can I trust the output?
Trust it as a starting point. One sample cannot tell you that a field is an enum, that a number is an integer, or that a string is a date — read it over and tighten it. It saves the typing, not the thinking.
What if my JSON starts with an array?
The type then describes one element, named with the name you type, and every element is read, so a field missing from some of them comes out optional. In TypeScript a last line adds a list type, such as OrderList = Order[]; with Zod, validate the whole list with z.array() around the schema.
Why is every number typed number, or float64 in Go, never integer?
Because a sample cannot prove a number is always whole: 24 today may be 24.5 tomorrow. TypeScript and Zod write number and Go writes float64. If an id or a quantity is always whole, change it to int or int64 in Go, or add .int() in Zod.
Is anything sent to a server?
No. It runs in your browser, so what you paste stays on your computer.

Related tools