BTC $61,430.00 +0.78% ETH $1,715.93 +0.20% USDT $0.9990 +0.05% BNB $560.58 +0.55% USDC $0.9996 +0.03% XRP $0.9529 +3.63% SOL $72.45 +2.79% TRX $0.3105 +1.97% FIGR_HELOC $1.04 — STETH $1,723.47 +0.11% HYPE $64.29 +3.26% ZEC $785.17 −0.34% XMR $488.41 −0.73% BSC-USD $0.9988 −0.04% BTC $61,430.00 +0.78% ETH $1,715.93 +0.20% USDT $0.9990 +0.05% BNB $560.58 +0.55% USDC $0.9996 +0.03% XRP $0.9529 +3.63% SOL $72.45 +2.79% TRX $0.3105 +1.97% FIGR_HELOC $1.04 — STETH $1,723.47 +0.11% HYPE $64.29 +3.26% ZEC $785.17 −0.34% XMR $488.41 −0.73% BSC-USD $0.9988 −0.04%

JSON to TypeScript, Go, PHP, Python and C#

Paste a JSON sample from an API and get ready-made types.

  • 100% Free
  • No sign-up
  • Runs in your browser

What is the JSON to TypeScript, Go, PHP, Python and C#?

Writing types by hand for an API answer is boring, and one wrong field name causes bugs later. Paste a sample of the JSON instead and get ready-made types in the language you use.

The tool walks through the whole document. Nested objects get their own named types, lists become arrays of the right type, numbers are split into whole numbers and decimals where the language cares, and when the items of a list have different fields, the fields that are not always there are marked optional. Keys that are not valid names, such as created-at, are kept with the right JSON tags.

Features

TypeScript

Interfaces with optional and null fields.

Go

Structs with json tags and omitempty.

PHP

Typed classes with nullable properties and array hints.

Python

Dataclasses with List and Optional.

C#

Classes with JsonPropertyName attributes.

Nested types

One named type per object, merged across list items.

How to use the JSON to TypeScript, Go, PHP, Python and C#

  1. 1

    Paste a JSON sample.

  2. 2

    Choose the language and the name of the main type.

  3. 3

    Copy the generated types.

Who it is for

Calling an API

Get types for an answer you just received.

Configuration files

Describe a JSON settings file in your code.

Learning a new language

See how the same data looks in Go, PHP or C#.

Tips for better results

  • Use a sample with all the fields filled in; fields that are null everywhere can only be typed as null or any.
  • Put several items in a list so the tool can see which fields are optional.
  • Change "Main type name" to the name of the thing, such as Order or User.

Your privacy: it stays on your device

  • This tool runs entirely in your browser. What you type and the files you choose are processed on your own device and are never sent to our server.
  • Nothing is uploaded, stored or kept in a history, so it is safe for private text, documents, photos and keys.
  • It keeps working on a slow connection, because no answer has to come back from a server.

Questions people ask

Is my JSON uploaded?

No. It is read and converted inside your browser.

How are optional fields found?

When a list holds several objects and a field is missing in some of them, that field is marked optional. A field that is null in the sample is marked nullable.

Can I convert a JSON array?

Yes. The main type becomes a list of the item type, and the item type is named after the main name.

FREE BITCOIN TOOLS

Stuck Bitcoin transaction?

Paste your TXID, see where it stands, and give it a free push. No signup, no wallet access.

Try the free accelerator
  • Free
  • No signup
  • Live status