JSON to Swift Converter

Generate Swift Codable models and CodingKeys from JSON samples. Infer nested structs and optional values without uploading your input.

How to generate Swift models

Paste a representative JSON object or array, choose a root type name and run the generator. Use the file selector to inspect each source file; Copy copies only the selected file. Download ZIP keeps all generated files together. Original JSON field names are mapped in complete output even when they are language keywords or contain punctuation.

Complete output uses Foundation and Codable, including decoding/encoding helpers and CodingKeys for renamed fields. Add the Swift file to your project; no third-party serialization library is required. Models-only mode creates plain structs and omits Codable support. Standard Codable encoding omits nil properties, so an explicit null may serialize as a missing field.

Samples, optional fields and limits

For several responses of the same shape, select JSON Lines and put one JSON document on each line. Fields missing from some object samples become optional; an explicit null contributes a nullable type. Empty arrays and null-only fields do not contain enough evidence to infer a precise element or value type. Add representative samples and review the generated model.

String values stay strings, including numeric IDs, dates and UUIDs. This infers a model from examples, not a full API contract. Limits: 200,000 characters, 64 nesting levels, 50 sample documents, 50 generated files and 1,000,000 output characters. Processing runs locally in a cancellable worker with a 10-second deadline.

Questions & answers

Are missing fields the same as null?

No. Missing fields indicate optional membership; null is a value. The target language may represent both through an optional or nullable type. Provide multiple samples and use All fields optional only when that matches your application.

Does this fetch schemas or send JSON to an API?

No. Only the JSON samples you enter are used. No schema URLs or JSON strings are fetched, and the generated program is not executed on this page.

Other Languages