Skip to content

API Response Types

Runs in your browser

Paste a real API response and get types you can trust. Every element of an array is read, not just the first, so a key that is missing once comes back optional rather than required.

Your JSON is processed locally in your browser and is not sent to our servers.

What was inferred

Paste a response to see which fields are optional, nullable or mixed

Generated types

The generated types show up here

How this one works

Every element of an array is read and merged, which is the whole point. Given [{"id":1,"nickname":"asha"}, {"id":2}], a converter that stops at the first element calls nickname a required string. It isn’t. It’s optional, and you find that out in production. Here a key missing anywhere becomes optional, a value that is sometimes null becomes nullable, and a field that is a string in one place and a number in another becomes a union rather than a guess.

Optional and nullable are kept apart, because they are different things: a field that can be absent is not the same as one that can be null, and only one of them needs a default. Each language then says it the way it can: ? in TypeScript, a pointer in Go, Option in Rust, | None in Python.

Two objects with identical fields become one named type, so a response carrying billing_address and shipping_address gives you one Address rather than two you have to merge. ISO timestamps are read as dates where the language has a date type, and snake_case keys are renamed to the casing the language expects, with the wire name kept in an annotation.

Questions

Why do I get better types if I paste more than one response?

Because optionality can only be observed. One object tells you which keys exist in that object; several tell you which keys are missing sometimes. Paste an array of real responses, or a list endpoint’s output, and the fields that vary come back optional instead of required.

What is the difference between optional and nullable here?

Optional means the key was absent from at least one sample. Nullable means the key was present with a null value. They need different code: an absent key needs a default or a question mark, a null value needs the type widened. Tools that collapse the two give you code that compiles and then fails on real data.

Is my JSON sent anywhere?

No. The inference and all nine generators are JavaScript running in this page, so a pasted response never leaves the tab. There is no server to receive it. Check your browser’s network panel while you type, or go offline and keep using it.

Why is a field typed as unknown or Any?

Because the sample gave nothing to go on: the value was null in every object, or the array was empty everywhere it appeared. Guessing a type there would be inventing one. Paste a sample where the field has a value and it will be inferred.

Should I use the Zod schema or the TypeScript interface?

The interface if the data is already yours; the schema if it is arriving over the network. An interface is a compile-time promise, and await response.json() is any, so the interface you assert into is a wish. A schema checks the same shape at the boundary, and you get the interface from it for free with z.infer.

Keyboard shortcuts

Global

  • Show this shortcuts dialogShift?
  • Toggle light / dark themeCtrlShiftL
  • Close dialogsEsc

Formatter & Validator

  • Format JSONCtrlEnter
  • Minify JSONCtrlShiftM
  • Copy outputCtrlShiftC
  • Download output as .jsonCtrlShiftS
  • Clear input and outputCtrlShiftX

Tree Viewer

  • Focus the search box/
  • Expand all nodesCtrlShiftE
  • Collapse all nodesCtrlShiftR

Diff

  • Swap document A and BCtrlShiftS

Time & date tools

  • Use the current time (Epoch Converter)CtrlEnter
  • Copy the main resultCtrlShiftC
  • Clear the inputCtrlShiftX

JSON tools

JSON FormatterPretty-print or minify
JSON ValidatorCheck strict JSON validity
JSON Tree ViewerBrowse JSON as a tree
JSON DiffCompare two documents
JSON Path FinderExplore JSONPath expressions
JSON → CSVFlatten JSON into rows
CSV → JSONTurn rows back into objects

JWT tools

JWT DecoderRead header, payload, claims
JWT VerifierCheck an HMAC signature
JWT Expiry Checkeriat, nbf and exp in local time
JWT GeneratorBuild a signed test token
Base64URL EncoderEncode or decode a segment

Time & date tools

Epoch ConverterTimestamps to real dates
Cron Expression ExplainerCron in plain English
Time Zone ConverterOne moment, many cities
Duration CalculatorDate maths and durations

Code formatters

SQL FormatterBeautify or minify SQL
HTML FormatterBeautify or minify HTML
CSS FormatterBeautify or minify CSS
JavaScript FormatterBeautify or minify JS
Markdown to HTMLConvert with a live preview

API tools

cURL ConvertercURL to code, ten ways
API Response TypesType an API response

Pages

JSON toolsFormat, validate, compare and convert JSON.
JWT toolsDecode, verify and generate JSON Web Tokens.
Time & date toolsConvert timestamps, read cron, compare zones.
Code formattersBeautify and minify SQL, HTML, CSS and JavaScript.
API toolsConvert cURL commands and type their responses.
HomePopular tools and categories
All categoriesBrowse tools by category
AboutWhat ToolJar is and why
PrivacyWhat is and is not collected

Theme

Switch to light theme
Switch to dark theme