# JSON to a TypeScript interface

**A single object shape.**

## Input

```json
{
  "id": 42,
  "name": "Ada Lovelace",
  "email": "ada@example.com",
  "active": true
}
```

## TypeScript

```typescript
export interface Root {
  id: number;
  name: string;
  email: string;
  active: boolean;
}
```

## Zod

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

export const RootSchema = z.object({
  id: z.number(),
  name: z.string(),
  email: z.string(),
  active: z.boolean(),
});
```

## 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-typescript-interface
JSON API: `POST https://json-to-types.gumballtools.com/api/v1/convert`
MCP endpoint: `https://json-to-types.gumballtools.com/api/mcp`
