Schema Codegen — JSON to Types & Schema

Paste sample JSON, a JSON Schema or an OpenAPI document to get type definitions in 10 formats. Put several samples in a row to infer optional keys and unions. Your data never leaves your device.

On-device・No uploadMobile friendlyWorks offline

Your files and input are processed only inside your browser on this device and are never uploaded to our servers.

No extra library needed. This is an inference from samples. It does not guarantee every value a real API can return.

Input (JSON, JSON Schema, OpenAPI)
0 characters0 lines
Generated code
Enter JSON or a schema on the left and the code appears here.

Enter JSON or a schema on the left and the code appears here.

How to use

  1. sample.json
    openapi.yaml

    Add sample data or a schema

  2. TypeScript, Zod and more

    Generate types and schemas

Feed in JSON or a schema to generate types in ten languages
  1. Paste sample JSON, a JSON Schema or an OpenAPI document (JSON / YAML) into the input pane, or click “Open file”. The sample buttons let you try it.

  2. Choose the output: TypeScript, Zod, JSON Schema, Go, Python, Kotlin, Swift, C#, Rust or Java. The result updates as you type.

  3. Adjust the root type name, how nested types are named, whether date-like strings become date types and whether integers are told from decimals. TypeScript and Python also have style options (interface / type, dataclass / Pydantic / TypedDict).

  4. To merge samples whose keys or types differ, paste several JSON documents one after another (JSON Lines works too). Keys missing from any sample become optional.

  5. Copy the result or download it as a file.

What it does

10 output formats

TypeScript (interface / type, readonly), Zod, JSON Schema (draft 2020-12), Go struct, Python (dataclass / Pydantic v2 / TypedDict), Kotlin data class, Swift Codable, C# record, Rust serde and Java record.

Merging several samples

With several JSON documents, keys present in only some become optional, a mix of integers and decimals becomes a decimal, values containing null become nullable and differing types become a union. An empty array never erases the element type seen in other samples.

Keys become valid identifiers

Reserved words (class, type…), symbols, spaces, leading digits, empty keys and non-ASCII keys are turned into identifiers valid in each language, and the original key is kept in a json tag, @SerialName and similar. Duplicate names get a number.

Schemas and OpenAPI as input

Reads JSON Schema and OpenAPI (2.0 / 3.x) components.schemas, with $ref, enum, nullable, allOf and oneOf / anyOf. YAML works too. $ref pointing to other files is not followed.

Date and number detection

Detects ISO 8601 date and date-time strings and lets you choose between date types and plain strings. Integers, decimals and 64-bit integers are told apart.

Processed on your device

Inference and generation run in a Web Worker in your browser and nothing is uploaded. Large input rarely freezes the page and is stopped after 30 seconds.

Use cases

  • Make TypeScript types or a Zod schema from an API response example
  • Make Go structs (with json tags) or Python dataclasses / Pydantic models from JSON
  • Make Kotlin, Swift, C#, Rust or Java models from OpenAPI components.schemas
  • Create a JSON Schema (draft 2020-12) from sample JSON for validation
  • Write down the shape of a config or stored data as types

Supported formats

Input

JSON (sample data, several documents, JSON Lines)JSON SchemaOpenAPI 2.0 / 3.x (JSON / YAML).json.yaml.yml.jsonl

Output

TypeScriptZodJSON Schema (draft 2020-12)GoPythonKotlinSwiftC#RustJava

Capability matrix

FeatureSupportNotes
Infer types from sample JSONSupportedMerges several samples
Generate from JSON Schema / OpenAPI components.schemasSupported$ref, enum, allOf and more
Detect date-like strings and switch to date typesSupported—
Turn keys into identifiers (reserved words, symbols, leading digits, empty)SupportedThe original key is kept in an attribute / tag
Mixed types (unions)PartialTypeScript, Zod, Python and JSON Schema use unions; other languages use an any-JSON-value type
Keys a Go json tag cannot hold (empty, quotes, commas…)PartialThose fields use json:"-" and a warning is shown
Fetching data from a real APINot supportedNo network access; paste the response instead
A guarantee that the types are completeNot supportedIt is an inference from samples; values or types that never appear are not reflected
External-file $ref, types from OpenAPI pathsNot supportedOnly components.schemas / $defs are read
Offline useSupportedWorks without a connection once loaded

Limits & notes

  • Input is limited to 5,000,000 characters.
  • Nesting is limited to 100 levels, and 500 documents when several are listed.
  • Up to 3,000 types and 500,000 values are analyzed. Beyond that an error is shown.
  • Processing is stopped after 30 seconds.
  • Integers with 19 or more digits are treated as decimals (floating point).
  • Non-string enums use only the value type, and description text is not included in the output.
  • Works on a phone, but PC is recommended for pasting long JSON.

Privacy & safety

Your JSON, schemas and files are processed only inside your browser. Nothing is sent to or stored on any server, so you can safely use responses from internal APIs. Closing the page clears the content.

FAQ

How do I generate TypeScript types from JSON?
Paste the JSON into the input pane and choose “TypeScript” as the output. You get an interface (or type); nested objects become separate types, arrays become T[] and values containing null become T | null.
Can I generate a Zod schema from JSON?
Yes. Choose “Zod” to get a z.object schema plus a z.infer type. Integers become z.number().int() and optional keys get .optional().
Is the type correct with only one sample?
It is inferred from what appears in that sample, so keys that are missing from it or non-null values that could appear are not reflected. Putting several samples with different keys or types in a row gets closer to the real shape.
Can I generate types from OpenAPI?
Yes. It reads components.schemas of an OpenAPI document (JSON / YAML) and generates a type per schema, with $ref, enum, nullable and allOf. Request and response bodies under paths are not read directly.
What happens to keys like class or type, or keys with symbols?
They become identifiers valid in each language (for example Rust’s type becomes type_, Kotlin’s class is backticked). The original key stays in json tags, @SerialName, @JsonProperty, serde rename and so on, so the mapping to JSON is kept.
Is my data sent to a server?
No. Everything runs in your browser; your input is never sent to LIBRA Works or any third party.

JSON Studio — Formatter & Validator

Paste JSON to format, minify or validate it instantly. Errors are shown with the exact line, column and cause, and comments or trailing commas can be auto-repaired. Your data never leaves your device.

No upload

OpenAPI Studio — Viewer & Validator

Paste an OpenAPI 3.0 / 3.1 or Swagger 2.0 definition to browse endpoints by tag and schemas as trees, and to check it against the official schemas with line and column. It never calls the API or fetches external files, and nothing leaves your device.

No upload

YAML / TOML Studio — Validate, Format & Convert

Paste YAML, TOML or JSON to validate, format or convert it. Errors show the exact line and column, and type traps such as “no becomes false” and anything lost in conversion are flagged up front. Your data never leaves your device.

No upload

CSV, JSON, XML & Excel Converter

Convert between CSV, TSV, JSON, JSON Lines, XML and Excel (.xlsx) by pasting or opening a file. Values stay as text by default, so zero-padded postal codes, phone numbers and long IDs are never changed. Everything runs in your browser; your data is not uploaded.

No upload

curl Converter

Paste “Copy as cURL” from Chrome or Firefox to see the method, URL, headers, cookies and body in tables, then convert to 12 kinds of code. The request is never sent and everything runs in your browser. Authorization and cookies can be hidden before you share.

No upload

Diff Tool — Text & Code Compare

Paste or drop two versions and see added and removed lines, plus the exact words that changed inside each line. Copy or save the result as a unified patch. Nothing leaves your browser.

No upload

Last updated: