Data to Class

JSON to Swift Converter

Paste any JSON document and get ready-to-use Codable structs or classes with CodingKeys when names differ — generated instantly in your browser.

Loading JSON to Swift…

How it works

How to use the JSON to Swift

  1. Paste JSON

    Paste a JSON object or array — for example an API response — or open a file.

  2. Tune the output

    Set the root type name and language-specific options. Nested objects get their own types named after their keys.

  3. Use the Swift code

    Decode with JSONDecoder().decode(Order.self, from: data).

How the Swift code is generated

The JSON is analysed value by value. Objects inside the same array are merged, so a property that appears only in some items becomes optional, values that are sometimes null become nullable, and identical nested shapes share a single type. Names are converted to Swift conventions, with serialization annotations wherever the original key differs.

Usage: Decode with JSONDecoder().decode(Order.self, from: data).

Built for developers

Why developers use it

  • Private by design

    Runs 100% in your browser. Nothing you paste is uploaded, logged or stored on a server.

  • Instant results

    Output updates as you type, with precise error locations when something is wrong.

  • Works offline

    Once loaded, the tool keeps working without a connection. Install it as an app if you like.

  • Free, no sign-up

    No accounts, no limits, no watermarks.

FAQ

Frequently asked questions

How are optional and nullable fields detected?

A property that is missing from some objects in an array is optional; a property that is null in the sample is nullable. The more representative your sample, the more accurate the types.

What happens with mixed types?

Values with different types in different samples become a union where Swift supports it, or the language's generic "any JSON value" type otherwise.

Is my data uploaded anywhere?

No. Everything runs locally in your browser — nothing you paste or open is sent to a server, logged or stored. The tool keeps working offline once the page has loaded.

Keep going

Related tools

Private by design

Your data never leaves your browser.

498 free tools that run locally — no uploads, no sign-up, no tracking of what you paste. They even work offline.

  • 498free tools
  • 0bytes uploaded
  • 23categories