JSON → Swift structs (Codable)

Client

Paste JSON to get structs with inferred property types and optional CodingKeys when keys do not match Swift names—review before shipping to production.

Learn more: JSON and Swift

Emit structs with `Codable` and optional `CodingKeys` when JSON keys differ from Swift property names—use with JSONDecoder/JSONEncoder in your app target.

Scope

Arrays infer from the first element only; numbers default to Double. Add optionals and custom decoding for dates, enums, and polymorphic payloads.

JSON → Swift

?

Parses JSON in your browser and emits classes inferred from the sample shape. Nested objects become nested types; arrays use the first element only to guess item shape. Nothing is uploaded.

Rename types, adjust CodingKeys when JSON keys differ from Swift property names, and align with JSONDecoder/JSONEncoder.

Common use cases

  • Prototype Codable structs for URLSession or Alamofire responses before adding manual CodingKeys.
  • Compare JSON key spelling with Swift property naming conventions.
  • Share scaffold structs when onboarding iOS teammates to a new endpoint.

Common mistakes to avoid

  • Skipping date or data decoding strategy

    ISO-8601 strings and epoch numbers need explicit strategies—generated types are only a starting point.

  • Treating optional keys as required

    Use optional properties when the server omits keys; one successful response does not prove always-present fields.

FAQ

Is Swift code generated locally?

Yes. JSON never leaves your browser for codegen.

Does this handle Swift 6 concurrency attributes?

It emits structural types. Add Sendable conformance or actor isolation per your app’s concurrency model.

Related utilities you can open in another tab—mostly client-side.