Loading...

JSON to TypeScript, Go, C#, Dart, Kotlin — Generate Models Free

Paste a JSON sample and instantly get strongly-typed models in TypeScript (interface), Go (struct with `json` tags), C# (class with `[JsonPropertyName]`), Dart (class with `fromJson` / `toJson`), or Kotlin (`@Serializable data class`). The tool merges field types across array elements, infers optional fields automatically when keys are missing in some objects, widens numeric types correctly (int vs float), and emits idiomatic code per language. Useful when you need to model an API response, generate models for a new microservice, scaffold Flutter DTOs, or just stop hand-typing 40-field models. Everything runs in your browser — your JSON, which may contain real customer data, never leaves the page.

Features

  • Five target languages

    TypeScript interfaces, Go structs with `json` tags, C# classes with `[JsonPropertyName]`, Dart classes with `fromJson`/`toJson`, Kotlin `@Serializable data class`es with `@SerialName`.

  • Smart type inference

    Detects integers vs floats, infers union types when arrays mix shapes, and marks fields optional when they only appear in some objects.

  • Per-language naming conventions

    Go uppercases initialisms (Id→ID, Url→URL, Api→API). C# uses PascalCase. Dart and Kotlin use camelCase with `@SerialName`/JSON-key mapping when needed.

  • Nested types extracted

    Each nested object becomes its own named type, so deeply nested JSON produces a clean, flat set of interfaces or structs.

  • Configurable root name

    Rename the top-level type to match your domain (User, Order, ApiResponse) — referenced types update automatically.

How to convert JSON to TypeScript or Go online

Paste, pick a language, copy the generated code.

  1. Paste your JSONDrop a representative JSON sample into the input panel — the richer the sample, the better the inference.
  2. Pick the target languageToggle TypeScript or Go. The output panel regenerates on every change.
  3. Name your root typeSet the root type name (default `Root`) to match your domain — try `User`, `Order`, `ApiResponse`.
  4. Copy into your projectClick Copy and paste the generated types directly into a `.ts` or `.go` file.

Examples

JSON → TypeScript interface

Input
{
  "id": 42,
  "name": "Alice",
  "is_active": true,
  "tags": ["admin", "beta"]
}
Output
export interface Root {
  id: number;
  name: string;
  is_active: boolean;
  tags: string[];
}

JSON → Go struct (with initialism uppercasing)

Input
{ "id": 1, "user_id": 42, "url": "https://x.test", "is_active": true }
Output
type Root struct {
	ID       int64  `json:"id"`
	UserID   int64  `json:"user_id"`
	URL      string `json:"url"`
	IsActive bool   `json:"is_active"`
}

JSON → C# class with [JsonPropertyName]

Input
{ "user_id": 1, "is_active": true }
Output
public class Root
{
    [JsonPropertyName("user_id")]
    public long UserId { get; set; }
    [JsonPropertyName("is_active")]
    public bool IsActive { get; set; }
}

JSON → Dart class with fromJson / toJson

Input
{ "id": 1, "user_name": "alice" }
Output
class Root {
  final int id;
  final String userName;

  Root({required this.id, required this.userName});

  factory Root.fromJson(Map<String, dynamic> json) { ... }
  Map<String, dynamic> toJson() { ... }
}

JSON → Kotlin @Serializable data class

Input
{ "user_id": 1, "is_active": true }
Output
@Serializable
data class Root(
    @SerialName("user_id") val userId: Long,
    @SerialName("is_active") val isActive: Boolean
)

Optional fields from a heterogeneous array

Input
[
  { "id": 1, "name": "a" },
  { "id": 2, "name": "b", "nickname": "bee" }
]
Output
export interface Root {
  id: number;
  name: string;
  nickname?: string;
}

`nickname` is optional because it appears in only some elements. Go emits `,omitempty`; C# emits `string?`; Dart drops `required`; Kotlin uses `String? = null`.

Frequently Asked Questions

Does my JSON get sent to a server?
No. JSON parsing, type inference, and code emission run entirely in client-side JavaScript. There is no backend involved — no logging, no analytics on your input. You can use this tool with real API responses that contain sensitive data.
How does the tool handle missing fields across array elements?
When you pass an array of objects, the tool unions the keys across all elements. Any key that does not appear in every element is marked optional (`field?:` in TypeScript, `,omitempty` in Go).
What happens when a field is `null`?
A `null` value alone produces `null` (TypeScript) or `interface{}` (Go). If the same field is `null` in some objects and `string` in others, the type becomes `string` and the field is marked optional. Future versions may offer a nullable mode (`string | null`).
Why are some Go field names uppercased like `ID` or `URL`?
Go style guides (effective Go, `golint`, `staticcheck`) require common initialisms to be all-caps. The emitter handles `Id, Url, Uri, Api, Http, Https, Json, Xml, Sql, Uuid, Ip, Tcp, Udp, Css, Html`. The original JSON key is preserved verbatim in the `json:"..."` tag.
Will it handle deeply nested JSON?
Yes. Each nested object becomes its own named interface/struct. Names are derived from the parent field — for example `posts: [...]` produces a `Post` type. Conflicts are resolved by suffixing with `2`, `3`, etc.
How does Dart `fromJson` / `toJson` work for nested types?
For each nested object field, `fromJson` calls the corresponding generated class's `.fromJson` factory; for lists of objects, it maps the JSON list through `T.fromJson(x as Map<String, dynamic>)`. `toJson()` does the inverse with `.toJson()` calls and `.map(...).toList()` for lists. Primitive numeric fields are coerced via `(x as num).toInt() / .toDouble()` to be tolerant of `42` vs `42.0` from APIs.
Why does Kotlin use `kotlinx.serialization` instead of Gson or Moshi?
`kotlinx.serialization` is the official, multi-platform serializer maintained by JetBrains, and it is the de-facto standard for new Kotlin code (server, Android, multiplatform). If you need Gson or Moshi output, file an issue — adding it is a small change.
What languages will you support next?
Java (POJO + Lombok), Rust (`serde`), Swift (`Codable`), and Python (Pydantic/dataclasses) are on the shortlist. Open an issue or message us to vote.