# JSON to TypeScript Interface Generator Online - JSON to Go Struct

> Free online JSON to TypeScript converter: interfaces or types from JSON, nested objects split into named interfaces, optional fields inferred, Go structs too.

- URL: https://qilingtools.com/en/json-to-ts
- Category: Developer Tools (https://qilingtools.com/en/dev)
- Tags: [Converters](https://qilingtools.com/en/tags/convert), [Developer](https://qilingtools.com/en/tags/dev), [Data Formats](https://qilingtools.com/en/tags/data)
- Last updated: 2026-10-26
- Price: Free, no sign-up
- Privacy: Runs locally in the browser; files are never uploaded

When integrating an API, paste a sample JSON response and get matching TypeScript type definitions instead of writing interfaces by hand. Nested objects become separate named interfaces (named after the field, with array items singularized), the shapes of multiple array elements are merged, fields missing from some elements are marked optional (?), and mixed arrays become union types. Choose interface or type style and whether to export; switch to the Go tab to generate Go structs with `json:"..."` tags, PascalCase field names and proper ID/URL initialisms. Everything happens in your browser.

## How to use

1. Paste the JSON (object or array) returned by your API
2. Set the root type name, choose interface / type and export, or switch to Go struct
3. Copy the generated types into your project

## Features

- Nested objects become named interfaces
- Array element shapes merged; missing fields become optional
- Mixed arrays produce unions like (number | string)[]
- interface or type style, optional export
- Keys that are not valid identifiers are quoted
- Identical object shapes reuse one type
- Go structs with json tags, omitempty and ID/URL initialisms
- Generated locally, nothing uploaded

## FAQ

### When is a field marked optional?

When a JSON array contains several objects and a field appears in only some of them, it becomes optional (key?: type). With "Treat null fields as optional" on, fields whose value is null are optional as well.

### How are interface names chosen?

The root uses the name you enter; nested objects use the field name in PascalCase (user_profile → UserProfile) and array items are singularized (items → Item). Clashing names get a numeric suffix, and identical shapes share one type.

### Are Go numbers int or float?

Integers become int64 and decimals float64; if a field mixes both it becomes float64. Nullable fields become pointer types so you can tell zero values from missing ones.

### Is my data uploaded?

No. Everything runs locally in your browser with no network upload and is discarded when you close the page, so it is safe for internal or sensitive data.

## Related tools

- [JSON Formatter](https://qilingtools.com/en/json): Free online JSON formatter: beautify or minify, validate with the exact line and column of any error, browse a collapsible tree, sort keys and escape strings.
- [Base64 Encode/Decode](https://qilingtools.com/en/base64): Free online Base64 encoder and decoder: UTF-8 safe, optional URL-safe variant, convert text to Base64 and back in real time. Processed locally, never uploaded.
- [URL Encode/Decode](https://qilingtools.com/en/url-encode): Free online URL encoder and decoder with encodeURIComponent and encodeURI modes. Escapes Chinese, spaces and special characters. Real-time and local, no upload.
- [JWT Decoder](https://qilingtools.com/en/jwt): Free online JWT decoder: decode the header and payload of a JSON Web Token, show expiry and issued-at times, all locally without uploading the token.
- [Timestamp Converter](https://qilingtools.com/en/timestamp): Free online Unix timestamp converter: convert timestamps and dates, auto-detect seconds or milliseconds, and show local, UTC, ISO 8601 and relative time.
- [Hash / Checksum](https://qilingtools.com/en/hash): Free online hash calculator: SHA-1, SHA-256, SHA-384 and SHA-512 of text or any file through the browser crypto API. Files never leave your device.
- [UUID Generator](https://qilingtools.com/en/uuid): Free online UUID generator: create RFC 4122 UUID v4 in bulk with a cryptographic RNG. Options for uppercase, no hyphens and braces, with one-click copy.
- [Base Converter](https://qilingtools.com/en/base-convert): Free online number base converter: convert between binary, octal, decimal, hexadecimal and any base 2–36. Uses BigInt for huge integers, computed locally.
