Load the sample
Start with the current JSON document, paste another sample, or combine several examples in an array.
Paste one or more representative JSON values, choose a target, and generate nested models locally. Review inferred optional fields and mixed types, then copy, export, or open the generated result as a new document.
The quality of an inferred model depends on the samples. Give the generator enough real variation to distinguish required fields, optional fields, arrays, nested objects, integers, decimals, booleans, and nulls.
Start with the current JSON document, paste another sample, or combine several examples in an array.
Set the root type name, select a language or JSON Schema, and optionally make every property optional.
Inspect the generation summary, copy the output, export it with the correct extension, or open it in CodePrettify.
The second deployment contains rollbackUrl while the first does not. That variation gives the generator evidence that the property should be optional.
Nested objects, arrays, timestamps, integers, booleans, and one conditionally present field.
[
{
"id": "deploy_7fb8c0e3",
"service": "api-gateway",
"actor": { "id": 42, "automated": true },
"regions": ["eu-north-1"],
"metrics": { "durationMs": 8421, "warnings": 0 }
},
{
"id": "deploy_91ca34d2",
"service": "formatter-worker",
"rollbackUrl": "https://deploy.example/rollback/91ca"
}
]
Property names and nested shapes stay tied to the JSON while generated types use the selected language conventions.
export interface DeploymentEventItem {
id: string;
service: string;
actor: Actor;
regions: string[];
metrics: Metrics;
rollbackUrl?: string;
}
export type DeploymentEvent =
DeploymentEventItem[];
The goal is not merely to produce code. It is to give the generator enough evidence to describe required, optional, nullable, nested, and repeated values without hiding uncertainty.
With JSON already open, choose More Actions → General tools → JSON to Code Generator and select Use document. You can also launch the generator first and paste a sample. Using the document avoids an extra copy and keeps the source nearby for verification.
Use an array of representative objects. This small practice sample proves that discountCode is conditional, shippedAt can be null, and tags contains strings even though one array is empty.
[
{
"id": 1001,
"status": "processing",
"discountCode": "SUMMER",
"shippedAt": null,
"tags": ["priority"]
},
{
"id": 1002,
"status": "shipped",
"shippedAt": "2026-07-24T14:32:00Z",
"tags": []
}
]
Set a root name such as Order, not Response or Data, unless the wrapper itself is the model you intend to keep. For package- or namespace-based targets, enter the destination used by your project so generated declarations arrive in the right context.
Choose TypeScript and generate. Confirm that the root remains an array, discountCode is optional because it is absent from one record, shippedAt permits null, and tags is a string array. If a result surprises you, inspect the input evidence before editing the generated code.
Choose Python + Pydantic, Zod, C#, or another target. Compare how each ecosystem expresses the same optional and nullable evidence. The syntax changes, but the inferred shape should remain consistent unless a language lacks a direct equivalent and must use a safer general type.
An empty array in every sample cannot reveal an element type. Genuinely mixed values may require a union or general type. A property seen in only one record becomes optional. Add another trustworthy sample when you have evidence; do not add invented values simply to silence a warning.
Copy, export with the suggested extension, or open the generated output as a CodePrettify document. Compile it, run your serializer, and test representative payloads. Generated models are a starting point: domain validation, naming conventions, precision, date parsing, and framework configuration still belong to your application.
Duplicate the sample and make one controlled change, then regenerate. This is the fastest way to learn how inference reacts.
shippedAt and observe optional plus nullable behavior.user-id and inspect the target’s alias or field mapping.tags array empty and read the unknown-element warning.The same inference model drives every output target. That makes it easy to compare how TypeScript, validation schemas, backend models, systems languages, and mobile types express the same data.


BaseModel, aliases JSON property names, and exposes optional values.A property missing from any object sample becomes optional. You can also force every generated property to be optional.
Whole and fractional values inform integer or number types. Null participates in a nullable or union type instead of being discarded.
Repeated object shapes become named definitions so generated output is easier to read and maintain.
Language-specific reserved words and invalid identifiers are renamed or represented through aliases where the target supports them.
When samples disagree, the generator uses a compatible union or general type rather than pretending every value has one shape.
Input size, output size, depth, and inspected values are capped so a pathological sample cannot lock the interface indefinitely.
The JSON sample is not sent to an inference API. This is deterministic model generation performed by the installed CodePrettify runtime.
Inference describes observed JSON; it cannot know the complete business contract. Review the generated result by separating facts proved by the sample from rules that only your application knows.
| Generated decision | Why it happened | What you should verify |
|---|---|---|
| Required property | The property appeared in every object sample. | Can the real API omit it in errors, partial responses, or older versions? |
| Optional property | At least one sampled object omitted it, or “all optional” was selected. | Is absence different from an explicit null in your domain? |
| Nullable or union type | The sample contained null or incompatible value kinds. | Should the application accept every observed type, or reject inconsistent source data? |
| Integer versus general number | Observed values were whole numbers or included fractions. | Could IDs exceed safe numeric precision, and should monetary values use a decimal type? |
| Nested model name | A repeated object shape became a reusable declaration. | Does the generated name match your domain vocabulary and project conventions? |
| Aliased property | The JSON key was invalid or reserved in the target language. | Does the serializer annotation preserve the exact source key during round trips? |
Check whether unrelated object shapes were placed in the same array or whether sparse partial responses were mixed with full records. Separate different domain types when they should not be merged.
At least one trustworthy sample needs a populated array. If no example exists, keep the safe unknown type and refine it from the API contract rather than guessing.
Inspect whether the sample root is an array, a wrapper object, or the entity itself. Rename the root for the concept your code will use and keep transport wrappers only when they matter.
Type declarations do not automatically enforce runtime rules. Use Zod or JSON Schema when runtime validation is required, then add domain constraints the sample could not infer.
Learning outcome: you should be able to point to the sample evidence behind every optional, nullable, nested, array, and mixed-value decision—and identify which domain rules still require human review.
It is a strong starting point inferred from the samples you provide. Review naming, domain constraints, validation rules, serialization settings, and optionality before treating it as a finished contract.
Yes. Choose “Use document” in the generator to load the current JSON without copying it manually.
Use an array containing several representative objects, including examples where conditionally present fields are absent.
Generate JSON Schema, open or copy it, then use CodePrettify’s JSON Schema Validator against the original document.
Open a JSON payload, generate the target model locally, and keep the source and result inside the same developer workspace.