Converters

JSON to Code Generator

Paste a JSON sample and get typed model classes or structs in the language of your choice. Supports 11 languages including TypeScript, Swift, Kotlin, Go, Rust, Python, C#, Java, Dart, Ruby, and PHP. The tool infers types from the JSON structure, generates named types for nested objects, and handles arrays and optional fields.

JSON to Code — Generate typed models from JSON (TypeScript, Swift, Kotlin, Go…)

What it does

  • Generates typed models from JSON in 11 languages
  • Supports TypeScript, Swift, Kotlin, Go, Rust, Python, C#, Java, Dart, Ruby, PHP
  • Infers types from JSON structure — strings, numbers, booleans, arrays, nested objects
  • Configurable top-level type name and naming style (PascalCase, camelCase, snake_case)
  • Types-only mode for clean output without serialization helpers

Use cases

  • Generating Swift or Kotlin models from an API's JSON response
  • Creating TypeScript interfaces for a REST API client
  • Generating Go structs from a JSON config file
  • Building Rust or Python data classes from JSON sample data

How it works

1

Paste your JSON sample into the input pane

2

Select your target language from the dropdown

3

Optionally set the top-level type name and naming style

4

The generated code appears in the output pane, ready to copy

Frequently asked questions

1How does it name the generated types?

You can set the top-level type name (default is Root). Nested objects get names derived from their parent key — for example, a key called "address" inside a "user" object becomes an Address type. The naming style (PascalCase, camelCase, snake_case) is configurable.

2Does it handle arrays of objects?

Yes. Arrays of objects generate a type for the array item, and the property is typed as an array of that type (e.g., List<Item> in Java, [Item] in Swift, Item[] in TypeScript).

3What's the 'Types only' option?

When enabled, the tool generates only the type definitions (interfaces, structs, classes) without any serialization or deserialization helper code. This produces cleaner output that you can use with your own JSON parsing library.

Related tools

Use JSON to Code offline in Devinity

All 95 tools run locally on your Mac. No internet required, no data sent to servers.

Download Devinity →