# JSON to a Zod schema

**A single object shape.**

## Input

```json
{
  "userId": 7,
  "nickname": null,
  "tags": ["admin", "beta"]
}
```

## TypeScript

```typescript
export interface Root {
  userId: number;
  nickname: null;
  tags: string[];
}
```

## Zod

```typescript
import { z } from 'zod';

export const RootSchema = z.object({
  userId: z.number(),
  nickname: z.null(),
  tags: z.array(z.string()),
});
```

## Warnings

### Whole numbers are still `number` (info)

Every numeric value in the sample was a whole number, but JSON has a single number type and cannot express the difference. The output uses `number`.

**Fix:** If a field is genuinely an integer, tighten it by hand: `z.number().int()`.

---

Canonical URL: https://json-to-types.gumballtools.com/types/json-to-zod-schema
JSON API: `POST https://json-to-types.gumballtools.com/api/v1/convert`
MCP endpoint: `https://json-to-types.gumballtools.com/api/mcp`
